Skip to content

fix(auth): Normalize credential auth handoff - #588

Merged
dcramer merged 8 commits into
mainfrom
fix/egress-auth-signal-only
Jun 10, 2026
Merged

dcramer merged 8 commits into
mainfrom
fix/egress-auth-signal-only

Conversation

@dcramer

@dcramer dcramer commented Jun 10, 2026 •

Copy link
Copy Markdown
Member

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 see GitHub, Notion, or Sentry instead 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/junior test suite, including Slack and architecture boundary checks.

Closes #589.


View Session in Sentry

dcramer and others added 2 commits June 10, 2026 19:49
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>
@vercel

vercel Bot commented Jun 10, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
junior-docs Ready Ready Preview, Comment Jun 10, 2026 10:41pm

Request Review

…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>
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]>
@dcramer dcramer changed the title fix(auth): consume egress auth signals unconditionally, remove heuristic detection fix(auth): Normalize sandbox egress auth handoff Jun 10, 2026
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]>
@dcramer dcramer changed the title fix(auth): Normalize sandbox egress auth handoff fix(auth): Normalize credential auth handoff Jun 10, 2026
@dcramer
dcramer merged commit e5b1d4c into main Jun 10, 2026
16 checks passed
@dcramer
dcramer deleted the fix/egress-auth-signal-only branch June 10, 2026 22:49

This branch was successfully deployed

1 active deployment
Preview – junior-docs — 624d2430 Deployed Jun 10, 2026 by vercel[bot]
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.

Normalize egress auth-required for broker-backed OAuth

1 participant