Skip to content

[plan] Fix broken error chain in run_workflow_validation.go ExitError branch #18279

@github-actions

Description

@github-actions

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

  • The ExitError branch uses %w to wrap the original error
  • Stderr content is still included in the error message for diagnostics
  • errors.As(returnedErr, &exec.ExitError{}) returns true for the ExitError case
  • Existing tests pass

Generated by Plan Command for issue #discussion #18227

  • expires on Feb 27, 2026, 6:22 AM UTC

Metadata

Metadata

Labels

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions