diff --git a/pkg/workflow/command_dispatch_validation.go b/pkg/workflow/command_dispatch_validation.go index 26099191279..5f0f012ba75 100644 --- a/pkg/workflow/command_dispatch_validation.go +++ b/pkg/workflow/command_dispatch_validation.go @@ -3,8 +3,12 @@ package workflow import ( "fmt" "strings" + + "github.com/github/gh-aw/pkg/logger" ) +var commandDispatchValidationLog = logger.New("workflow:command_dispatch_validation") + // validateCommandWorkflowDispatchInputs rejects required workflow_dispatch inputs when // slash_command or label_command triggers are configured. // Returns an error if any workflow_dispatch input has required: true. @@ -19,6 +23,9 @@ func validateCommandWorkflowDispatchInputs(workflowData *WorkflowData) error { return nil } + commandDispatchValidationLog.Printf("Validating workflow_dispatch inputs: slash_command=%v, label_command=%v", + hasSlashCommand, hasLabelCommand) + onMap, ok := workflowData.RawFrontmatter["on"].(map[string]any) if !ok { return nil @@ -51,6 +58,8 @@ func validateCommandWorkflowDispatchInputs(workflowData *WorkflowData) error { } triggerNamesPhrase := strings.Join(triggerNames, " and ") + commandDispatchValidationLog.Printf("Rejecting required workflow_dispatch input %q because triggers %s cannot supply manual inputs", + inputName, triggerNamesPhrase) return fmt.Errorf( "on.workflow_dispatch.inputs.%s.required: true is not allowed when using %s; these triggers are dispatched automatically and cannot enforce required manual inputs; set required: false in workflow_dispatch.inputs", inputName, triggerNamesPhrase, @@ -58,5 +67,6 @@ func validateCommandWorkflowDispatchInputs(workflowData *WorkflowData) error { } } + commandDispatchValidationLog.Printf("Workflow_dispatch inputs validation passed: input_count=%d", len(inputsMap)) return nil } diff --git a/pkg/workflow/error_recovery.go b/pkg/workflow/error_recovery.go index 7249ba06275..c0f2368b0f1 100644 --- a/pkg/workflow/error_recovery.go +++ b/pkg/workflow/error_recovery.go @@ -4,8 +4,12 @@ import ( "errors" "sort" "strings" + + "github.com/github/gh-aw/pkg/logger" ) +var errorRecoveryLog = logger.New("workflow:error_recovery") + // ErrorSeverity classifies how urgently a compilation error should be fixed. type ErrorSeverity int @@ -44,6 +48,7 @@ func ExpandErrorMessages(err error) []string { return nil } + errorRecoveryLog.Print("Expanding error messages from compilation error") var messages []string collectErrorMessages(err, &messages) if len(messages) == 0 { @@ -109,9 +114,11 @@ func shouldSuppressWrapperMessage(message string) bool { // BuildPrioritizedErrorReportFromMessages classifies, suppresses, and limits messages. func BuildPrioritizedErrorReportFromMessages(messages []string, showAll bool) PrioritizedErrorReport { + errorRecoveryLog.Printf("Building prioritized error report: message_count=%d, show_all=%v", len(messages), showAll) prioritized, suppressedCount := prioritizeErrorMessages(messages) displayed := prioritized if !showAll && len(displayed) > 5 { + errorRecoveryLog.Printf("Truncating displayed errors from %d to top 5 (set show_all=true to see all)", len(displayed)) displayed = displayed[:5] } @@ -125,6 +132,8 @@ func BuildPrioritizedErrorReportFromMessages(messages []string, showAll bool) Pr report.RecoveryPlan = buildRecoveryPlan(prioritized, suppressedCount) } + errorRecoveryLog.Printf("Prioritized report ready: total=%d, displayed=%d, hidden=%d, suppressed=%d, has_plan=%v", + report.TotalCount, len(report.DisplayedErrors), report.HiddenCount, report.SuppressedCount, report.RecoveryPlan != nil) return report } @@ -162,6 +171,10 @@ func prioritizeErrorMessages(messages []string) ([]PrioritizedError, int) { prioritized = append(prioritized, candidate) } + if hasCriticalSyntax { + errorRecoveryLog.Printf("Critical syntax errors detected, suppressed %d cascading errors", suppressedCount) + } + if len(prioritized) == 0 { prioritized = candidates suppressedCount = 0 diff --git a/pkg/workflow/gh_aw_setup_steps.go b/pkg/workflow/gh_aw_setup_steps.go index c37995b11ce..4a0aead7d3e 100644 --- a/pkg/workflow/gh_aw_setup_steps.go +++ b/pkg/workflow/gh_aw_setup_steps.go @@ -3,8 +3,12 @@ package workflow import ( "fmt" "sort" + + "github.com/github/gh-aw/pkg/logger" ) +var ghAwSetupLog = logger.New("workflow:gh_aw_setup_steps") + type ghAwSetupStepConfig struct { actionMode ActionMode ifCondition string @@ -16,7 +20,10 @@ type ghAwSetupStepConfig struct { } func generateGhAwSetupStep(config ghAwSetupStepConfig) (GitHubActionStep, error) { + ghAwSetupLog.Printf("Generating gh-aw setup step: action_mode=%s, action_repo=%s, cli_version=%s, with_field_count=%d", + config.actionMode, config.actionRepo, config.cliVersion, len(config.withFields)) if config.actionMode == ActionModeDev { + ghAwSetupLog.Print("Using dev mode: build and install gh-aw CLI from source") step := GitHubActionStep{" - name: Build and install gh-aw CLI from source"} if config.ifCondition != "" { step = append(step, " if: "+config.ifCondition) @@ -36,6 +43,11 @@ func generateGhAwSetupStep(config ghAwSetupStepConfig) (GitHubActionStep, error) // Pinning errors are non-fatal: we still emit a valid step with the fallback // action reference so compilation and workflow execution can continue. actionRef, pinErr := resolveGhAwSetupActionRef(config) + if pinErr != nil { + ghAwSetupLog.Printf("Action ref resolution returned non-fatal error: %v (using fallback ref %s)", pinErr, actionRef) + } else { + ghAwSetupLog.Printf("Resolved action ref: %s", actionRef) + } step := GitHubActionStep{ " - name: Install gh-aw extension", } @@ -70,18 +82,24 @@ func resolveGhAwSetupActionRef(config ghAwSetupStepConfig) (string, error) { return actionRef, err } if pinnedRef != "" { + ghAwSetupLog.Printf("Using workflow-aware action pin: %s", pinnedRef) return pinnedRef, nil } + ghAwSetupLog.Printf("No workflow-aware pin available, falling back to repo@tag: %s", actionRef) return actionRef, nil } actionRef := getActionPin(config.actionRepo) if actionRef != "" { + ghAwSetupLog.Printf("Using static action pin: %s", actionRef) return actionRef, nil } if config.fallbackActionRefTag != "" { - return fmt.Sprintf("%s@%s", config.actionRepo, config.fallbackActionRefTag), nil + fallback := fmt.Sprintf("%s@%s", config.actionRepo, config.fallbackActionRefTag) + ghAwSetupLog.Printf("Using fallback action ref tag: %s", fallback) + return fallback, nil } + ghAwSetupLog.Printf("Using bare action repo (no ref): %s", config.actionRepo) return config.actionRepo, nil }