This repository was archived by the owner on Oct 23, 2026. It is now read-only.
Repository navigation
feat(sdk): Add headers option to createSentrySDK - #1465
Merged
Merged
Conversation
Consumers of the programmatic SDK, such as the Sentry bundler plugins, need to send extra HTTP headers to self-hosted instances behind a reverse proxy (Google IAP, Cloudflare Access). Until now the only way was to set `SENTRY_CUSTOM_HEADERS` on `process.env` before invoking a command, which is process-global state. `SentryOptions.headers` maps onto `SENTRY_CUSTOM_HEADERS` in the isolated env of each invocation, so the existing self-hosted guard, forbidden-header list, and origin trust checks all apply unchanged. Values containing a separator are rejected up front, since they would otherwise parse into a bogus extra header. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
BYK
approved these changes
Aug 25, 2026
BYK
left a comment
Member
There was a problem hiding this comment.
I'd love to avoid the unnecessary serialize->deserialize dance but other than that looks pretty good, thanks!
| /** | ||
| * Serialize a header map into the `SENTRY_CUSTOM_HEADERS` string format. | ||
| * | ||
| * Inverse of {@link parseCustomHeaders}: the result round-trips through it. |
Member
There was a problem hiding this comment.
Can we not avoid the round-trip and unnecessary string serialize/deserialize waste?
Member
Author
There was a problem hiding this comment.
Waste has been reduced and dancing got prohibited. It's now as clean as it can get
Review feedback: serializing `SentryOptions.headers` into the `SENTRY_CUSTOM_HEADERS` string only for `parseCustomHeaders` to split it again was wasted work, and it forced a separator restriction on values. `setCustomHeadersOverride` now installs the validated name/value pairs for the current invocation directly, next to `setEnv`, and `getCustomHeaders` prefers them over the env var and SQLite defaults. Name validation is shared with the string parser, and the self-hosted guard and origin trust check are unchanged. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
BYK
approved these changes
Aug 25, 2026
5 tasks
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 subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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.
Consumers of the programmatic SDK, such as the Sentry bundler plugins, need to send extra HTTP headers to self-hosted instances behind a reverse proxy (Google IAP, Cloudflare Access). Until now the only way was to set
SENTRY_CUSTOM_HEADERSonprocess.envbefore invoking a command, which is process-global state.SentryOptions.headersmaps ontoSENTRY_CUSTOM_HEADERSin the isolated env of each invocation, so the existing self-hosted guard, forbidden-header list, and origin trust checks all apply unchanged. Values containing a separator are rejected up front, since they would otherwise parse into a bogus extra header.