Skip to content

shell.exec raises on a non-zero exit instead of returning the result, and the captured stderr is lost #824

Open

Description

@David-Noble-at-work

shell.exec returns a *Result carrying stdout, stderr and the exit code, and its doc says the
result is still returned on a non-zero exit "with whatever was captured". From Starlark it is not:
a non-zero exit raises, and the caller never sees the result.

Observed

r = shell.exec(command = "gh issue list --json number")
if r.exit_code != 0:
    fail("gh issue list failed: " + r.stderr.strip())

When gh exits 4 (not authenticated), the if is never reached. The user sees:

Error in shell.exec: exit status 4

gh's own message — the thing that says why — was captured into Result.Stderr and discarded on
the way out. Every exit_code check in Starlark is unreachable code.

Wanted

One of:

  • return the result on non-zero exit, as the Go doc already promises, and let the script decide, or
  • keep raising, but include the captured stderr in the error.

Observed under noblefactor-ops#140 Phase 1. Belongs with #800's bypass of pkg/process, since a
single bridge is where this rule lives once.

Activity

  1. David-Noble-at-work commented on Nov 9, 2026

    @David-Noble-at-work
    ContributorAuthor

    star github triage sweep added this issue to Triage: devlore, for the rules it breaks:

    • severity: a Bug whose Severity is blank; a bug is Critical, High, Medium or Low
    • no-evidence: no Evidence of completion section
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions