MCPcopy Create free account
hub / github.com/github/gh-aw / parseIssueReportingConfig

Method parseIssueReportingConfig

pkg/workflow/missing_issue_reporting.go:57–140  ·  view source on GitHub ↗
(outputMap map[string]any, yamlKey, defaultTitle string, defaultCreateIssue bool, parseReportAsFailure bool, debugLog *logger.Logger)

Source from the content-addressed store, hash-verified

55}
56
57func (c *Compiler) parseIssueReportingConfig(outputMap map[string]any, yamlKey, defaultTitle string, defaultCreateIssue bool, parseReportAsFailure bool, debugLog *logger.Logger) *IssueReportingConfig {
58 configData, exists := outputMap[yamlKey]
59 if !exists {
60 return nil
61 }
62
63 // Explicitly disabled: missing-data: false
64 if configBool, ok := configData.(bool); ok && !configBool {
65 debugLog.Printf("%s configuration explicitly disabled", yamlKey)
66 return nil
67 }
68
69 cfg := &IssueReportingConfig{}
70
71 // Enabled with no value: missing-data: (nil)
72 if configData == nil {
73 debugLog.Printf("%s configuration enabled with defaults", yamlKey)
74 createIssueStr := strconv.FormatBool(defaultCreateIssue)
75 cfg.CreateIssue = &createIssueStr
76 if parseReportAsFailure {
77 trueVal := "true"
78 cfg.ReportAsFailure = &trueVal
79 }
80 cfg.TitlePrefix = defaultTitle
81 cfg.Labels = []string{}
82 return cfg
83 }
84
85 if configMap, ok := configData.(map[string]any); ok {
86 debugLog.Printf("Parsing %s configuration from map", yamlKey)
87 c.parseBaseSafeOutputConfig(configMap, &cfg.BaseSafeOutputConfig, 0)
88
89 // Pre-process create-issue to support literal booleans and GitHub Actions expressions.
90 if err := preprocessBoolFieldAsString(configMap, "create-issue", debugLog); err != nil {
91 debugLog.Printf("Invalid create-issue value for %s: %v", yamlKey, err)
92 return nil
93 }
94
95 if createIssueVal, exists := configMap["create-issue"]; exists {
96 if createIssueStr, ok := createIssueVal.(string); ok {
97 cfg.CreateIssue = &createIssueStr
98 debugLog.Printf("create-issue: %s", createIssueStr)
99 }
100 } else {
101 createIssueStr := strconv.FormatBool(defaultCreateIssue)
102 cfg.CreateIssue = &createIssueStr
103 }
104
105 // Parse report-as-failure field (only for missing-tool and missing-data, not report-incomplete)
106 if parseReportAsFailure {
107 if err := preprocessBoolFieldAsString(configMap, "report-as-failure", debugLog); err != nil {
108 debugLog.Printf("Invalid report-as-failure value for %s: %v", yamlKey, err)
109 return nil
110 }
111 if reportAsFailureVal, exists := configMap["report-as-failure"]; exists {
112 if reportAsFailureStr, ok := reportAsFailureVal.(string); ok {
113 cfg.ReportAsFailure = &reportAsFailureStr
114 debugLog.Printf("report-as-failure: %s", reportAsFailureStr)

Callers 3

Calls 4

PrintfMethod · 0.45

Tested by

no test coverage detected