Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions pkg/workflow/command_dispatch_validation.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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
Expand Down Expand Up @@ -51,12 +58,15 @@ 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,
)
}
}

commandDispatchValidationLog.Printf("Workflow_dispatch inputs validation passed: input_count=%d", len(inputsMap))
return nil
}
13 changes: 13 additions & 0 deletions pkg/workflow/error_recovery.go
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -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]
}

Expand All @@ -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
}

Expand Down Expand Up @@ -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
Expand Down
20 changes: 19 additions & 1 deletion pkg/workflow/gh_aw_setup_steps.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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)
Expand All @@ -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",
}
Expand Down Expand Up @@ -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
}
Loading