Repository navigation
fix(secrets): Do not treat x-session-affinity as a credential - #27
Merged
Merged
Conversation
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>
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.
Problem
CREDENTIAL_HEADERinsrc/secrets.tsmatchessession, so the proxy learns the value ofx-session-affinityas 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 calledstopAgent({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: addNOT_CREDENTIAL_HEADERS, a set of header names that match the pattern but carry no credential. It has onlyx-session-affinity.learnskips these headers. The broad pattern does not change for other headers.README.md: say that the proxy does not learnx-session-affinity.tests/service.test.ts: the local upstream echoesx-session-affinity. A new test sends it withx-api-keythrough a real proxy. The client response and the recording keep the affinity value, and thex-api-keyvalue stays redacted.Tests
pnpm checkpasses (format, lint, typecheck, knip, tests).src/secrets.ts(affinitycomes 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]