Skip to content

Fix error wrapping in compiler_yaml_main_job.go#14433

Closed
Copilot wants to merge 2 commits intomainfrom
copilot/standardize-error-wrapping
Closed

Fix error wrapping in compiler_yaml_main_job.go#14433
Copilot wants to merge 2 commits intomainfrom
copilot/standardize-error-wrapping

Conversation

Copy link
Contributor

Copilot AI commented Feb 7, 2026

Error wrapping audit found getAgenticEngine error returned unwrapped at line 191, breaking error chain traceability.

Changes

  • Line 191: Wrap error with context and %w
    // Before
    if err != nil {
        return err
    }
    
    // After
    if err != nil {
        return fmt.Errorf("failed to get agentic engine: %w", err)
    }

Analysis

Error wrapping coverage: 3/3 (100%)

  • Line 79: Repository imports marshal error ✓
  • Line 191: Agentic engine error ✓ (fixed)
  • Line 401: Step ordering validation error ✓

Other fmt.Errorf without %w: 16 instances across compiler files are validation errors that correctly create new error messages rather than wrapping existing ones (e.g., type validation, missing field errors).

Warning logs: 5 instances (message serialization, hash computation, import parsing) represent intentional graceful degradation where failures are non-fatal.

Original prompt

This section details on the original issue you should resolve

<issue_title>[Code Quality] Standardize error wrapping across compiler files</issue_title>
<issue_description>## Description

Compiler files have inconsistent error wrapping patterns. Some files properly wrap errors with %w (89% in compiler_jobs.go) while others only wrap 50% of errors (compiler_yaml_main_job.go). Standardizing error wrapping improves error traceability and debugging.

Current State

  • compiler_yaml_main_job.go: 1/2 errors wrapped (50%)
  • compiler_activation_jobs.go: 4/4 errors wrapped (100%) ✅
  • Issue: Line 66 in compiler_yaml_main_job.go - error only logged, not returned

Example Issues

Before (Line 66):

if err != nil {
    compilerYamlLog.Printf("Warning: failed to marshal repository imports: %v", err)
}

After:

if err != nil {
    return fmt.Errorf("failed to marshal repository imports for merge step: %w", err)
}

Suggested Changes

  1. Audit all fmt.Errorf calls in compiler files
  2. Ensure consistent %w usage when wrapping errors
  3. Fix line 66 in compiler_yaml_main_job.go - return error instead of just logging
  4. Add error context where missing

Files Affected

  • pkg/workflow/compiler_yaml_main_job.go (1 error needs fixing)
  • pkg/workflow/compiler_activation_jobs.go (9 missing %w - if not already fixed)
  • Other compiler files in pkg/workflow/compiler_*.go (audit needed)

Success Criteria

  • All fmt.Errorf calls use %w when wrapping errors
  • No errors are only logged without being returned
  • All existing tests continue to pass
  • Error messages include helpful context

Priority

High - Improves error traceability and debugging experience

Estimated Effort

30-60 minutes

Source

Extracted from:

Listed as "Immediate Action" in both compiler quality reports.

AI generated by Discussion Task Miner - Code Quality Improvement Agent

  • expires on Feb 7, 2026, 9:07 PM UTC

Comments on the Issue (you are @copilot in this section)


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

- Wrap getAgenticEngine error with %w for proper error tracing
- Line 191: Changed from `return err` to `return fmt.Errorf("failed to get agentic engine: %w", err)`
- All tests pass

Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Copilot AI changed the title [WIP] Standardize error wrapping across compiler files Fix error wrapping in compiler_yaml_main_job.go Feb 7, 2026
Copilot AI requested a review from pelikhan February 7, 2026 22:21
@pelikhan pelikhan closed this Feb 8, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Code Quality] Standardize error wrapping across compiler files

2 participants