-
Notifications
You must be signed in to change notification settings - Fork 46
Open
Labels
automationcode-qualitycookieIssue Monster Loves Cookies!Issue Monster Loves Cookies!refactoringtask-mining
Description
Description
Implement panic recovery (defer recover()) in critical compilation and GitHub API operation paths to prevent workflow crashes from unexpected panics. Currently zero panic recovery implementations exist across the entire codebase.
Problem
Complex operations (compilation, GitHub API calls, file I/O, JSON parsing) lack safety nets. A single unhandled panic in production crashes entire workflow runs, resulting in poor error messages and production incidents.
Suggested Changes
Files to Update
pkg/workflow/compiler.go- Main compilation entry pointspkg/workflow/compiler_yaml.go- YAML generation operationspkg/cli/trial_command.go- Trial workflow executionpkg/cli/add_interactive.go- Interactive workflow creationpkg/cli/init.go- Repository initialization
Implementation Pattern
func CriticalOperation() (err error) {
defer func() {
if r := recover(); r != nil {
err = fmt.Errorf("panic during operation: %v\nstack trace:\n%s",
r, string(debug.Stack()))
if log.Enabled() {
log.Printf("Recovered from panic: %v", r)
}
}
}()
// Existing operation code...
return nil
}Success Criteria
- Add panic recovery to main compiler entry points (
Compile,CompileWorkflow,CompileAction) - Add panic recovery to GitHub API client operations
- Add panic recovery to interactive CLI commands (init, add, trial)
- Recovered panics converted to proper errors with stack traces in debug logs
- Add test cases verifying panic recovery converts to errors
Testing
func TestCompiler_PanicRecovery(t *testing.T) {
tests := []struct {
name string
setupPanic func()
wantErr string
}{
{
name: "nil pointer panic",
setupPanic: func() { var x *int; _ = *x },
wantErr: "panic during",
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
err := recoverableOperation(tt.setupPanic)
assert.Error(t, err)
assert.Contains(t, err.Error(), tt.wantErr)
})
}
}Source
Extracted from Error Experience Engineering Discussion #12265
Priority
High - Prevents production crashes from unexpected panics
Estimated Effort
Medium (2-3 days)
AI generated by Discussion Task Miner - Code Quality Improvement Agent
- expires on Feb 18, 2026, 9:08 PM UTC
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
automationcode-qualitycookieIssue Monster Loves Cookies!Issue Monster Loves Cookies!refactoringtask-mining