Skip to content

fix(secrets): Do not treat x-session-affinity as a credential - #27

Merged
dcramer merged 1 commit into
mainfrom
fix/session-affinity-not-credential
Nov 4, 2026
Merged

dcramer merged 1 commit into
mainfrom
fix/session-affinity-not-credential

Conversation

@sentry-junior

@sentry-junior sentry-junior Bot commented Nov 4, 2026

Copy link
Copy Markdown
Contributor

Problem

CREDENTIAL_HEADER in src/secrets.ts matches session, so the proxy learns the value of x-session-affinity as a credential. The recorder redacts the live response before it records it and before the client gets it. So each copy of that value in a response becomes <<redacted>> for the client too.

Vercel AI Gateway clients send x-session-affinity: <conversation id>. This header is not a secret. It only pins the provider for prompt caching (docs). In getsentry/junior evals, a model response that repeated the conversation id came back as <<redacted>>. The model then called stopAgent({conversation_id: "<<redacted>>"}), and the subagents eval failed. Junior worked around this in getsentry/junior#2636: it drops the header in eval requests. Each Roach tenant that sends this header gets the same corruption.

Change

  • src/secrets.ts: add NOT_CREDENTIAL_HEADERS, a set of header names that match the pattern but carry no credential. It has only x-session-affinity. learn skips these headers. The broad pattern does not change for other headers.
  • README.md: say that the proxy does not learn x-session-affinity.
  • tests/service.test.ts: the local upstream echoes x-session-affinity. A new test sends it with x-api-key through a real proxy. The client response and the recording keep the affinity value, and the x-api-key value stays redacted.

Tests

  • pnpm check passes (format, lint, typecheck, knip, tests).
  • The new test fails without the change in src/secrets.ts (affinity comes back as <<redacted>>).

Follow-up

After Roach deploys, getsentry/junior can revert the header removal from #2636 in packages/junior-evals/src/eval-ai-gateway-dispatcher.ts, so evals get prompt cache affinity back. This PR does not make that change.

via @dcramer.

--

View Session [Sentry]

AI Gateway clients send a conversation id in x-session-affinity. The
proxy learned it as a credential and replaced it with <<redacted>> in
the model responses that the client got.

Co-Authored-By: David Cramer <23610+dcramer@users.noreply.github.com>
@dcramer
dcramer marked this pull request as ready for review November 4, 2026 00:50
@dcramer
dcramer merged commit 3570141 into main Nov 4, 2026
15 checks passed
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.

1 participant