Repository navigation
Description
PR #588 made plugin auth detection signal-only (egress proxy is authoritative, no bash text heuristics). This follow-up aligns the broker-backed credential path with the plugin-hook path and fills the unhandled upstream-rejection case.
Background
Two credential-needed paths currently exist in the egress layer:
Plugin hook path (e.g. GitHub):
issueCredential hook → { type: "needed", authorization: {...} }
→ SandboxEgressCredentialNeededError (self-describing, carries auth context)
→ proxy writes auth_required signal
Broker path (all simple oauth-bearer plugins, e.g. Sentry):
oauth-bearer-broker → throws CredentialUnavailableError
→ proxy catches raw error, separately calls getPluginOAuthConfig()
→ proxy reconstructs authorization context, writes auth_required signal
The broker is already the shared OAuth implementation for simple providers — it handles token lookup, scope checking, refresh, and lease issuance. Simple plugins should not need their own issueCredential hook. The gap is that the broker path doesn't produce a self-describing egress error; the proxy has to look up authorization context separately.
Scope
Part 1 — Normalize credential-needed at the egress boundary
Convert broker-backed CredentialUnavailableError into SandboxEgressCredentialNeededError in egress-credentials.ts, before it reaches the proxy. Both paths should converge on one canonical error type so the proxy handles a single credential-needed contract:
egress-credentials.ts:
broker throws CredentialUnavailableError
→ convert to SandboxEgressCredentialNeededError with provider, grant, authorization
(same as plugin hook path already does)
proxy:
one handler for SandboxEgressCredentialNeededError → auth_required signal
The proxy's separate CredentialUnavailableError reconstruction path goes away.
Part 2 — Handle upstream auth rejection for broker-injected bearer credentials
Currently unhandled:
broker finds token → proxy injects bearer → upstream returns 401
→ no auth_required signal emitted → no re-auth triggered
Add core egress response classification for broker-backed OAuth bearer leases. When an authenticated request is rejected upstream with an auth-invalid response, core should emit the same auth_required signal. This should be shared infrastructure, not per-plugin OAuth logic.
Non-goals
- Simple OAuth-bearer plugins must not need to implement their own token storage, refresh, or issuance hooks
- No bash/stdout auth heuristics (removed in fix(auth): Normalize credential auth handoff #588)
- No changes to OAuth pause UX or Redis signal transport
- GitHub multi-grant credential behavior is unchanged
Acceptance criteria
- Broker missing-token and scope-gap cases produce the same canonical
SandboxEgressCredentialNeededErroras plugin hook providers, with authorization context embedded - Proxy no longer reconstructs authorization context from
CredentialUnavailableErrorfor the broker path - When a broker-injected bearer token is rejected by the upstream (401), an
auth_requiredsignal is emitted without per-plugin OAuth code in the plugin package - Tests cover: broker no-token, broker scope-gap, plugin-hook needed, broker upstream-401-after-injection
- PR fix(auth): Normalize credential auth handoff #588 behavior is preserved: auth orchestration uses structured signal only
Refs #588.
Activity
fix(egress): normalize broker CredentialUnavailableError at the egres…
fix(auth): Normalize credential auth handoff (getsentry#588)
ref(agent): Remove model handoff, Turn router, and model profiles (#2681
perf(briefs): Generate Briefs with the fast model (#2719)