-
Notifications
You must be signed in to change notification settings - Fork 341
[plan] Fix broken error chain in run_workflow_validation.go ExitError branch #18279
Description
Objective
Fix an inconsistent error wrapping in run_workflow_validation.go where the ExitError branch discards the original error, breaking errors.Is/errors.As chain inspection for callers.
Context
From Sergo analysis run §22372431560 (discussion #18227).
In pkg/cli/run_workflow_validation.go around line 286–290, the ExitError branch uses %s with only the stderr bytes, silently dropping the original error from the chain. The sibling branch immediately below correctly uses %w. This inconsistency means callers cannot use errors.As(err, &exec.ExitError{}) on the returned error for the case that matters most.
Current Code
// pkg/cli/run_workflow_validation.go:286-290
var exitError *exec.ExitError
if errors.As(err, &exitError) {
return fmt.Errorf("failed to list workflows in repository '%s': %s",
repoOverride, string(exitError.Stderr)) // ❌ %s drops original error
}
return fmt.Errorf("failed to list workflows in repository '%s': %w", repoOverride, err) // ✅ correctApproach
Wrap the original err in the ExitError branch while still including the stderr output for diagnostics:
var exitError *exec.ExitError
if errors.As(err, &exitError) {
return fmt.Errorf("failed to list workflows in repository '%s': %s: %w",
repoOverride, string(exitError.Stderr), err) // ✅ includes stderr AND wraps err
}
return fmt.Errorf("failed to list workflows in repository '%s': %w", repoOverride, err)This preserves the original error chain so callers can still use errors.As(err, &exec.ExitError{}) on the returned error.
Files to Modify
pkg/cli/run_workflow_validation.go(~line 286–290)
Acceptance Criteria
- The
ExitErrorbranch uses%wto wrap the original error - Stderr content is still included in the error message for diagnostics
-
errors.As(returnedErr, &exec.ExitError{})returnstruefor theExitErrorcase - Existing tests pass
Generated by Plan Command for issue #discussion #18227
- expires on Feb 27, 2026, 6:22 AM UTC