Skip to content

[Code Quality] Standardize error wrapping across compiler files #14282

Description

@github-actions

Description

Compiler files show inconsistent error wrapping patterns. Some files use fmt.Errorf with %w for proper error chaining (excellent), while others have gaps that make debugging compilation failures more difficult.

Current State

Error wrapping inconsistency across files:

File Error Wraps Coverage Status
compiler_jobs.go 16/16 100% ✅ Excellent
compiler_yaml.go 3/3 100% ✅ Excellent
compiler_activation_jobs.go 4/9 44% ⚠️ Needs work
compiler_yaml_main_job.go 1/2 50% ⚠️ Needs work

Examples of issues:

  1. compiler_yaml_main_job.go (line 66):

    // Current - error only logged, not returned
    if err != nil {
        compilerYamlLog.Printf("Warning: failed to marshal repository imports: %v", err)
    }
    
    // Should be
    if err != nil {
        return fmt.Errorf("failed to marshal repository imports for merge step: %w", err)
    }
  2. compiler_activation_jobs.go:

    • 9 fmt.Errorf calls total
    • Only 4 use %w for wrapping (44% coverage)
    • Missing context propagation for debugging

Impact

Without consistent error wrapping:

  • Harder to trace compilation failures through call stack
  • Loss of error context at higher levels
  • Debugging requires more time and effort
  • Reduced error actionability for users

Suggested Changes

  1. Audit all compiler files for error handling:

    grep -rn "return.*fmt.Errorf" pkg/workflow/compiler*.go | grep -v "%w"
  2. Fix missing error wrapping - Ensure all error returns use %w:

    return fmt.Errorf("failed to (action): %w", err)
  3. Return errors instead of only logging - Don't swallow errors:

    // Bad
    if err != nil {
        log.Printf("Warning: %v", err)
    }
    
    // Good  
    if err != nil {
        return fmt.Errorf("context: %w", err)
    }

Files Affected

Priority order (most gaps to fewest):

  1. pkg/workflow/compiler_activation_jobs.go - 5 missing wraps
  2. pkg/workflow/compiler_yaml_main_job.go - 1 missing wrap

Success Criteria

  • All fmt.Errorf calls with underlying errors use %w wrapper
  • No errors are logged without being returned (unless explicitly intended)
  • Error messages include actionable context
  • Grep audit shows 100% error wrap coverage: grep -rn "return.*fmt.Errorf" pkg/workflow/compiler*.go | grep -v "%w" returns no results
  • All existing tests still pass after changes

Priority

High - Quick win with high impact on debugging experience

Estimated Effort

30-60 minutes

Source

Extracted from compiler quality analysis discussions:

Identified as immediate action in both reports due to impact on debugging.

AI generated by Discussion Task Miner - Code Quality Improvement Agent

  • expires on Feb 8, 2026, 5:17 AM UTC

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions