-
Notifications
You must be signed in to change notification settings - Fork 122
Preserve error chains with IDE-friendly multi-line formatting #14434
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
|
@copilot what do the errors look like like? |
Errors follow the IDE-parseable format: Example 1: File Not Found Example 2: YAML Parse Error Example 3: Validation Error Key changes:
Selective wrapping:
This provides more debugging information while maintaining clean, IDE-parseable error messages. |
|
@copilot this is not good. The compiler error should point to the exact source location and the error nesting must one per line. They must be IDE friendly. |
Changed formatCompilerError to use custom error type that: - Keeps IDE-parseable first line (file:line:col: type: message) - Adds nested errors on separate lines with indentation - Preserves error chain for errors.Is() and errors.As() This addresses the feedback that errors must be one per line and IDE-friendly. Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Fixed in commit e0b563f. Errors now use multi-line format: BEFORE (single line - not IDE friendly): AFTER (multi-line - IDE friendly): Changes:
Custom |
formatCompilerError()was breaking error chains by callingerr.Error(), preventing use oferrors.Is()anderrors.As()for debugging. Additionally, errors were formatted on a single line, making them difficult for IDEs to parse.Changes
Custom
compilerErrortype with multi-line formatting:Error format comparison:
BEFORE (single line - not IDE friendly):
AFTER (multi-line - IDE friendly):
Key improvements:
file:line:col: type: messageerrors.Is(),errors.As(),errors.Unwrap()all work)Selective wrapping pattern:
nilfor low-level errors likeos.PathError(avoids exposing internals)Updates:
compiler.goandagent_validation.goerrors.Is()anderrors.Unwrap()behaviorcompiler_activation_jobs.go,compiler_yaml.go,compiler_yaml_main_job.goalready follow correct patternsOriginal prompt
This section details on the original issue you should resolve
<issue_title>[Code Quality] Standardize error wrapping across compiler files with %w format verb</issue_title>
<issue_description>Error handling practices vary inconsistently across compiler files, with some files properly using
%wfor error wrapping and others not wrapping at all. This breaks error chains and makes debugging compilation failures significantly harder.Problem
Current inconsistency:
compiler_jobs.go: 16 instances offmt.Errorf(..., %w)✅ (Excellent)compiler_activation_jobs.go: 4 out of 13fmt.Errorfcalls use%w(31% coverage)compiler.go: 0 instances of%wwrapping ❌ (UsesformatCompilerError()which doesn't wrap)compiler_yaml.go: 3 instances of%wwrappingcompiler_yaml_main_job.go: 1 instance of%wwrappingWhy this matters:
errors.Is()anderrors.As()%wImpact Examples
❌ Current (No Wrapping):
Result: When compilation fails, we see a generic error message but lose the root cause (e.g., file not found, YAML parse error).
✅ After Fix (With Wrapping):
Result: Full error chain is preserved, allowing
errors.Unwrap()to trace back to root cause.Suggested Changes
1. Update
formatCompilerError()incompiler.go(HIGH)2. Add wrapping to
compiler_activation_jobs.go(MEDIUM)Audit 13
fmt.Errorfcalls, update 9 missing%w:3. Add wrapping to
compiler_yaml.go(LOW)Ensure all error returns use
%w(currently 3, may have more to fix).4. Add wrapping to
compiler_yaml_main_job.go(LOW)Increase from 1 to all error paths.
Files Affected
pkg/workflow/compiler.go- UpdateformatCompilerError()signaturepkg/workflow/compiler_activation_jobs.go- Update 9 error returnspkg/workflow/compiler_yaml.go- Audit and update error returnspkg/workflow/compiler_yaml_main_job.go- Audit and update error returnsImplementation Approach
Phase 1: Fix
formatCompilerError()(30 min)%wPhase 2: Audit Each File (1-2 hours)
Phase 3: Verify (30 min)
make test-unit- ensure tests passmake lint- check for issuesSuccess Criteria
formatCompilerError()wraps cause errors with%w%wfor error wrappingmake test-unit)errors.Is()anderrors.As()make agent-finish)Priority
MEDIUM - Not breaking functionality, but impacts debugging experience and code quality.
Estimated Effort
2-3 hours total (mostly audit and mechanical changes)
Source
Extracted from discussions...
✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.