Skip to content

[Code Quality] Add fmt.Errorf(%w) error context wrapping to compiler.go (7 bare return err calls) #45673

Description

@github-actions

Description

compiler.go has 7 bare return err calls and zero fmt.Errorf("%w") wraps, stripping all context from error paths through the main entry point. This makes debugging failures hard — the error reaches callers with no indication of which operation failed.

This was identified in the Daily Compiler Code Quality Report where compiler.go scored 67/100, with error handling being a key weakness (10/20).

Suggested Changes

  • Replace all 7 bare return err calls in compiler.go with return fmt.Errorf("<operation>: %w", err) patterns
  • Each wrapping message should describe the operation being attempted at that call site

Files Affected

  • pkg/compiler/compiler.go (7 error return sites)

Success Criteria

  • grep -n 'return err$' pkg/compiler/compiler.go returns zero results
  • All error paths include context via fmt.Errorf("...: %w", err)
  • make fmt && make lint passes
  • Existing tests continue to pass

Source

Extracted from [daily-compiler-quality] Daily Compiler Code Quality Report - 2026-07-15 (discussion #45594)

Priority

High (30 min effort) — minimal risk change with immediate improvement to error debuggability

🔍 Task mining by Discussion Task Miner - Code Quality Improvement Agent · 204.4 AIC · ⌖ 5.13 AIC · ⊞ 7K ·

  • expires on Jul 15, 2026, 11:40 PM UTC-08:00

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions