Skip to content

[plan] Implement debug logging for critical error paths #9239

@github-actions

Description

@github-actions

Objective

Add structured debug logging to critical error paths in workflow compilation, MCP configuration, and validation systems to improve troubleshooting capabilities.

Context

Currently only 11 debug logs exist for error paths - insufficient for troubleshooting production issues. The top 5 high-impact error sites need comprehensive debug logging to aid developers in diagnosing workflow issues.

Files to Modify

High-impact files with complex error paths:

  • pkg/workflow/compiler_orchestrator.go (44 error returns)
  • pkg/workflow/mcp-config.go (999 LOC)
  • pkg/workflow/runtime_setup.go (1,016 LOC)
  • pkg/workflow/permissions.go (953 LOC)
  • pkg/workflow/safe_outputs_config_generation.go (854 LOC)

Approach

Add debug logging using the existing logger package:

import "github.com/githubnext/gh-aw/pkg/logger"

var log = logger.New("workflow:compiler_orchestrator")

func someValidation() error {
    log.Printf("Starting validation for workflow: %s", workflowName)
    
    if err := validate(); err != nil {
        log.Printf("Validation failed: %v (context: %+v)", err, contextData)
        return fmt.Errorf("validation failed: %w", err)
    }
    
    log.Printf("Validation completed successfully")
    return nil
}

Follow logger naming convention: "workflow:filename" (e.g., "workflow:compiler_orchestrator")

Add logging for:

  1. Operation start/completion
  2. Validation failures with context
  3. Configuration parsing steps
  4. Permission checks
  5. MCP server initialization

Acceptance Criteria

  • Debug logging added to all 5 high-impact error sites
  • Logs include structured context (file, operation, input values)
  • Uses existing logger package with appropriate namespaces
  • Logs only appear when DEBUG environment variable matches
  • No performance impact when debug logging disabled
  • Follows "workflow:filename" naming convention

Validation

Test debug logging:

# Enable debug logs
DEBUG=workflow:* ./gh-aw compile test-workflow.md

# Verify logs appear for error paths
DEBUG=workflow:compiler_orchestrator ./gh-aw compile invalid-workflow.md

# Check performance (no impact when disabled)
time ./gh-aw compile test-workflow.md

Related to #9236

AI generated by Plan Command for discussion #9231

Metadata

Metadata

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions