From b226e86cc09af75404251839199b310ae8447c27 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Mon, 1 Jun 2026 04:57:47 +0000 Subject: [PATCH 1/2] Add debug logging to token/offset/input helpers Add logger package debug logging to four pkg/ helpers following the pkg:filename naming convention: - workflow:daily_effective_workflow - log each branch of max-daily-effective-tokens resolution (frontmatter, imported config, default fallbacks) - workflow:utc_offset - log format-mismatch, out-of-range, and successful normalization in NormalizeUTCOffset - typeutil (reused shared typeutilLog) - log parse and int64-overflow rejections in ParseInt64KMSuffix - types:input_definition - log fallback coercion of unexpected default value types in GetDefaultAsString All log arguments are side-effect-free. Co-Authored-By: Claude Opus 4.8 (1M context) --- pkg/types/input_definition.go | 5 +++++ pkg/typeutil/effective_token_limits.go | 2 ++ pkg/workflow/daily_effective_workflow.go | 8 ++++++++ pkg/workflow/utc_offset.go | 10 +++++++++- 4 files changed, 24 insertions(+), 1 deletion(-) diff --git a/pkg/types/input_definition.go b/pkg/types/input_definition.go index 4218628f8ab..9b29fed252e 100644 --- a/pkg/types/input_definition.go +++ b/pkg/types/input_definition.go @@ -3,8 +3,12 @@ package types import ( "fmt" "strconv" + + "github.com/github/gh-aw/pkg/logger" ) +var inputDefinitionLog = logger.New("types:input_definition") + // InputDefinition defines an input parameter for workflows, safe-jobs, and imported workflows. // The structure follows the workflow_dispatch input schema from GitHub Actions: // https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#onworkflow_dispatchinputs @@ -41,6 +45,7 @@ func (i *InputDefinition) GetDefaultAsString() string { } return fmt.Sprintf("%g", v) default: + inputDefinitionLog.Printf("Coercing default value of unexpected type %T to string via fallback formatting", v) return fmt.Sprintf("%v", v) } } diff --git a/pkg/typeutil/effective_token_limits.go b/pkg/typeutil/effective_token_limits.go index a7be0585f37..45f22deb1b4 100644 --- a/pkg/typeutil/effective_token_limits.go +++ b/pkg/typeutil/effective_token_limits.go @@ -30,9 +30,11 @@ func ParseInt64KMSuffix(raw string) (int64, bool) { parsed, err := strconv.ParseInt(trimmed, 10, 64) if err != nil || parsed <= 0 { + typeutilLog.Printf("Rejected K/M-suffixed value %q: not a positive base-10 integer", raw) return 0, false } if parsed > math.MaxInt64/multiplier { + typeutilLog.Printf("Rejected K/M-suffixed value %q: would overflow int64 (multiplier=%d)", raw, multiplier) return 0, false } return parsed * multiplier, true diff --git a/pkg/workflow/daily_effective_workflow.go b/pkg/workflow/daily_effective_workflow.go index d71f96a0a6b..d70a2a0d8ec 100644 --- a/pkg/workflow/daily_effective_workflow.go +++ b/pkg/workflow/daily_effective_workflow.go @@ -5,10 +5,13 @@ import ( "strconv" "strings" + "github.com/github/gh-aw/pkg/logger" "github.com/github/gh-aw/pkg/typeutil" "github.com/github/gh-aw/pkg/workflow/compilerenv" ) +var dailyEffectiveWorkflowLog = logger.New("workflow:daily_effective_workflow") + const maxDailyEffectiveTokensField = "max-daily-effective-tokens" // parseMaxDailyEffectiveTokensValue normalizes max-daily-effective-tokens @@ -70,20 +73,25 @@ func resolveMaxDailyEffectiveTokensFromRaw(raw any) (*string, bool) { func resolveMaxDailyEffectiveTokens(frontmatter map[string]any, importedJSON string) *string { if value, found := resolveMaxDailyEffectiveTokensFromRaw(frontmatter[maxDailyEffectiveTokensField]); found { + dailyEffectiveWorkflowLog.Print("Resolved max-daily-effective-tokens from workflow frontmatter") return value } if importedJSON == "" { + dailyEffectiveWorkflowLog.Print("No frontmatter value and no imported config; falling back to default max-daily-effective-tokens") defaultValue := compilerenv.ResolveDefaultMaxDailyEffectiveTokens("") return parseMaxDailyEffectiveTokensValue(defaultValue) } var imported any if err := json.Unmarshal([]byte(importedJSON), &imported); err != nil { + dailyEffectiveWorkflowLog.Printf("Failed to unmarshal imported max-daily-effective-tokens JSON, using default: %v", err) defaultValue := compilerenv.ResolveDefaultMaxDailyEffectiveTokens("") return parseMaxDailyEffectiveTokensValue(defaultValue) } if value, found := resolveMaxDailyEffectiveTokensFromRaw(imported); found { + dailyEffectiveWorkflowLog.Print("Resolved max-daily-effective-tokens from imported config") return value } + dailyEffectiveWorkflowLog.Print("Imported config did not provide a usable value; falling back to default max-daily-effective-tokens") defaultValue := compilerenv.ResolveDefaultMaxDailyEffectiveTokens("") return parseMaxDailyEffectiveTokensValue(defaultValue) } diff --git a/pkg/workflow/utc_offset.go b/pkg/workflow/utc_offset.go index 39f2d7c2070..57ca70d070d 100644 --- a/pkg/workflow/utc_offset.go +++ b/pkg/workflow/utc_offset.go @@ -6,8 +6,12 @@ import ( "strconv" "strings" "time" + + "github.com/github/gh-aw/pkg/logger" ) +var utcOffsetLog = logger.New("workflow:utc_offset") + var utcOffsetPattern = regexp.MustCompile(`^([+-])(\d{2}):(\d{2})$`) // NormalizeUTCOffset validates and normalizes a numeric UTC offset. @@ -15,16 +19,20 @@ func NormalizeUTCOffset(raw string) (string, error) { trimmed := strings.TrimSpace(raw) matches := utcOffsetPattern.FindStringSubmatch(trimmed) if matches == nil { + utcOffsetLog.Printf("UTC offset %q does not match expected +HH:MM/-HH:MM format", trimmed) return "", fmt.Errorf("must be a numeric UTC offset like +00:00 or -08:00") } hours, _ := strconv.Atoi(matches[2]) minutes, _ := strconv.Atoi(matches[3]) if hours > 14 || minutes > 59 || (hours == 14 && minutes != 0) { + utcOffsetLog.Printf("UTC offset %q out of range (hours=%d, minutes=%d)", trimmed, hours, minutes) return "", fmt.Errorf("must be a numeric UTC offset like +00:00 or -08:00") } - return fmt.Sprintf("%s%02d:%02d", matches[1], hours, minutes), nil + normalized := fmt.Sprintf("%s%02d:%02d", matches[1], hours, minutes) + utcOffsetLog.Printf("Normalized UTC offset %q to %q", trimmed, normalized) + return normalized, nil } // ParseUTCOffsetLocation converts a numeric UTC offset to a fixed time.Location. From 5a97add6cb1e560fbfb631469c8c45a4a90529c3 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Mon, 1 Jun 2026 05:12:41 +0000 Subject: [PATCH 2/2] Fix discarded strconv.Atoi error returns in utc_offset.go Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com> --- pkg/workflow/utc_offset.go | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/pkg/workflow/utc_offset.go b/pkg/workflow/utc_offset.go index 57ca70d070d..b0360053bd4 100644 --- a/pkg/workflow/utc_offset.go +++ b/pkg/workflow/utc_offset.go @@ -23,8 +23,14 @@ func NormalizeUTCOffset(raw string) (string, error) { return "", fmt.Errorf("must be a numeric UTC offset like +00:00 or -08:00") } - hours, _ := strconv.Atoi(matches[2]) - minutes, _ := strconv.Atoi(matches[3]) + hours, err := strconv.Atoi(matches[2]) + if err != nil { + return "", fmt.Errorf("must be a numeric UTC offset like +00:00 or -08:00") + } + minutes, err := strconv.Atoi(matches[3]) + if err != nil { + return "", fmt.Errorf("must be a numeric UTC offset like +00:00 or -08:00") + } if hours > 14 || minutes > 59 || (hours == 14 && minutes != 0) { utcOffsetLog.Printf("UTC offset %q out of range (hours=%d, minutes=%d)", trimmed, hours, minutes) return "", fmt.Errorf("must be a numeric UTC offset like +00:00 or -08:00") @@ -42,8 +48,14 @@ func ParseUTCOffsetLocation(raw string) (*time.Location, error) { return nil, err } - hours, _ := strconv.Atoi(normalized[1:3]) - minutes, _ := strconv.Atoi(normalized[4:6]) + hours, err := strconv.Atoi(normalized[1:3]) + if err != nil { + return nil, fmt.Errorf("invalid UTC offset format: %w", err) + } + minutes, err := strconv.Atoi(normalized[4:6]) + if err != nil { + return nil, fmt.Errorf("invalid UTC offset format: %w", err) + } offsetSeconds := hours*60*60 + minutes*60 if normalized[0] == '-' { offsetSeconds = -offsetSeconds