Skip to content

Pass along stderr from failed external auth helper invocations#327

Closed
benweint wants to merge 1 commit into
rest-sh:mainfrom
benweint:external-auth-error-reporting
Closed

Pass along stderr from failed external auth helper invocations#327
benweint wants to merge 1 commit into
rest-sh:mainfrom
benweint:external-auth-error-reporting

Conversation

@benweint
Copy link
Copy Markdown

@benweint benweint commented Apr 24, 2026

This change passes along the stderr from an external auth helper, if the helper exits with a non-zero exit status. It also makes the message reported for external auth tool invocation failures more descriptive.

Today, when an external auth helper exits with a non-zero exit code, restish shows an error like this:

With this entry in apis.json:

  "example": {
    "base": "https://httpbin.org",
    "profiles": {
      "default": {
        "auth": {
          "name": "external-tool",
          "params": {
            "commandline": "echo 'bad news' >&2 && exit 1"
          }
        }
      }
    },

... attempting to use this API yields

❯ restish example /status/200
panic: exit status 1

goroutine 1 [running]:
github.com/rest-sh/restish/cli.MakeRequest(0x14000001900, {0x1400069fc30, 0x2, 0x1016be803?})
	/workspace/cli/request.go:244 +0x1298
github.com/rest-sh/restish/cli.Load({0x1400013ed08, 0x13}, 0x140000dec08)
	/workspace/cli/api.go:209 +0x4bc
github.com/rest-sh/restish/cli.Run()
	/workspace/cli/cli.go:821 +0xef4
main.main()
	/workspace/main.go:40 +0x2f4

Which notably lacks the error message produced by the external auth helper. This is obviously a contrived example, but given how finicky auth can be, those errors are often critical to debugging.

Here's how this looks after the change:

❯ restish  example /status/200
panic: external auth tool failed: exit status 1: bad news

... snip ...

@benweint benweint force-pushed the external-auth-error-reporting branch from 9838ca0 to a428b89 Compare April 24, 2026 05:33
@benweint benweint marked this pull request as ready for review April 24, 2026 05:36
@danielgtaylor
Copy link
Copy Markdown
Collaborator

Thanks for the PR. I re-checked this against v2.0.0, and failed external-tool auth now includes a bounded stderr excerpt in the error message.

I verified the focused external-tool auth tests before closing; the v2 path reports errors in the shape:

external-tool auth: tool exited with error: ... stderr: ...

This v1-era patch is superseded by the v2 implementation, so I’m closing it out. Thanks again for pushing on the debugging experience here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants