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) // ✅ correct
Approach
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
Generated by Plan Command for issue #discussion #18227
Objective
Fix an inconsistent error wrapping in
run_workflow_validation.gowhere theExitErrorbranch discards the original error, breakingerrors.Is/errors.Aschain inspection for callers.Context
From Sergo analysis run §22372431560 (discussion #18227).
In
pkg/cli/run_workflow_validation.goaround line 286–290, theExitErrorbranch uses%swith 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 useerrors.As(err, &exec.ExitError{})on the returned error for the case that matters most.Current Code
Approach
Wrap the original
errin theExitErrorbranch while still including the stderr output for diagnostics: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
ExitErrorbranch uses%wto wrap the original errorerrors.As(returnedErr, &exec.ExitError{})returnstruefor theExitErrorcase