Repository navigation
fix(auth): Normalize credential auth handoff - #588
Merged
Merged
Conversation
Piped bash commands (e.g. `sentry org list --json 2>&1 | head -20`) mask the underlying CLI's non-zero exit code with 0 from the pipe tail (head, grep, etc.). The previous exit-code guard prevented auth/permission signals from being consumed when the outer shell returned 0, so the Sentry (and other provider) OAuth flow was never triggered. The egress auth signal is a side-channel from the network layer, not a property of shell exit status. Consuming it unconditionally is safe because `clearSandboxEgressSignals` runs before each bash execution, preventing signals from a previous command bleeding into the current one. Fixes the case where `sentry org list ... | head` returned exit 0 despite a proxy 401, causing no OAuth link to be sent to the user. Co-Authored-By: claude-opus-4-5 <[email protected]> Co-Authored-By: sentry-junior[bot] <264270552+sentry-junior[bot]@users.noreply.github.com>
…tic detection The previous auth orchestration had two detection paths: 1. Structured egress signal (auth_required field from the egress proxy) 2. Heuristics: regex on stdout/stderr, provider inference from command text, exit-code gating Path 2 was brittle for two reasons: - Piped commands (e.g. `sentry org list | head`) exit 0 from the pipe tail, masking the CLI's real non-zero exit and bypassing the isCommandAuthFailure check entirely. - Provider inference from command text and stdout is fragile and error-prone. Root cause of the original bug: `sentry org list --json 2>&1 | head -20` returned exit_code 0, so neither path triggered and the user never received a Sentry OAuth link. Fix: - sandbox.ts: always consume auth/permission signals after bash execution, regardless of exit code. The egress signal is a network-layer side-channel and clearSandboxEgressSignals() prevents cross-command leakage. - plugin-auth-orchestration.ts: remove isCommandAuthFailure, commandTargetsProvider, registeredProviderNames, commandText, formatCommand. Rename handleCommandFailure -> maybeHandleAuthSignal. Auth is now detected exclusively through the structured auth_required field on the tool result. - agent-tools.ts: check for auth signal on all sandbox tool executions (isSandbox), not just bash commands. Remove bashCommand variable. Co-Authored-By: claude-opus-4-5 <[email protected]> Co-Authored-By: sentry-junior[bot] <264270552+sentry-junior[bot]@users.noreply.github.com>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
…s boundary
The broker oauth-bearer path was throwing CredentialUnavailableError directly
to the egress proxy, which then had to reconstruct OAuth authorization context
via a separate getPluginOAuthConfig() lookup.
This normalizes broker-sourced credential-needed failures to
SandboxEgressCredentialNeededError inside egress-credentials.ts before they
reach the proxy, so:
- The error is self-describing (carries provider, grant, authorization)
- The proxy handles one canonical auth-required error type
- The broker remains the shared OAuth implementation; no per-plugin hooks needed
CredentialUnavailableError now only reaches the proxy for plugin { type:
"unavailable" } results (non-user-actionable infra failures). The proxy's
handler for that case gains a defensive log if a broker error ever slips
through unnormalized.
Part 2 (upstream 401 after token injection) was already handled by the proxy's
UPSTREAM_TOKEN_REJECTION_STATUS path, which uses lease.authorization for all
lease types including broker-backed ones.
Closes #589.
Co-Authored-By: claude-opus-4-5 <[email protected]>
Co-Authored-By: sentry-junior[bot] <264270552+sentry-junior[bot]@users.noreply.github.com>
dcramer
marked this pull request as ready for review
June 10, 2026 21:05
Update stale agent tool tests to exercise the structured auth signal path and keep sandbox egress proxy logging mocks aligned with the Sentry surface used in CI. Add broker-backed OAuth coverage so missing user credentials record OAuth authorization metadata before plugin auth orchestration starts the resume flow. Co-Authored-By: GPT-5 Codex <[email protected]>
Keep sandbox bash execution sequential so egress auth signals remain scoped to the command that produced them. Preserve host-provided auth signal messages for non-OAuth credential failures before disabled-flow handling so operational GitHub failures do not look like user OAuth prompts. Co-Authored-By: GPT-5 Codex <[email protected]>
Expose one sandbox egress credential error with a kind instead of making the proxy catch unrelated broker and egress error classes. Keep broker CredentialUnavailableError as the lower-level input and translate it at the egress credential boundary alongside plugin credential results. Co-Authored-By: GPT-5 Codex <[email protected]>
Carry the egress credential outcome through the host-side auth signal so orchestration can distinguish OAuth-required credentials from unavailable provider setup. Refresh the auth specs around structured egress signals and remove the duplicated pipe-masked auth regression test. Co-Authored-By: GPT-5 Codex <[email protected]>
Require plugin manifests to provide a human-facing display name and use that label in OAuth and Slack auth-pause copy. Carry the display name through auth pause retry metadata so resumed turns can post uniform requester-targeted notices without deriving labels from provider ids. Co-Authored-By: GPT-5 Codex <[email protected]>
This branch was successfully deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Credential auth pauses now flow through structured provider metadata instead of derived labels or bash-output heuristics. Sandbox egress consumes auth and permission signals after every execution, broker-backed OAuth and plugin-managed credentials normalize into the same host-side auth signal shape, and auth resume errors now require provider identity plus a human-facing provider label before a turn can be parked.
Plugin manifests now require
display-name/displayName, and Slack/OAuth auth-pause copy reads that manifest-owned label so users seeGitHub,Notion, orSentryinstead of machine ids. The branch keeps GitHub credential issuance separate while making the missing, expired, or rejected OAuth intervention point uniform and contained for the rest of the pipeline.The current branch passes typecheck, lint, build, and the full
@sentry/juniortest suite, including Slack and architecture boundary checks.Closes #589.
View Session in Sentry