Skip to content
This repository was archived by the owner on Oct 23, 2026. It is now read-only.

feat(sdk): Add headers option to createSentrySDK - #1465

Merged
JPeer264 merged 2 commits into
mainfrom
jp/sdk-headers-option
Aug 25, 2026
Merged

JPeer264 merged 2 commits into
mainfrom
jp/sdk-headers-option

Conversation

@JPeer264

Copy link
Copy Markdown
Member

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.

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>
@JPeer264
JPeer264 requested a review from BYK August 25, 2026 06:20
@JPeer264 JPeer264 self-assigned this Aug 25, 2026
@vercel

vercel Bot commented Aug 25, 2026 •

Copy link
Copy Markdown

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

Project Deployment Actions Updated (UTC)
cli Ready Ready Preview Aug 25, 2026 9:39am

Request Review

Comment thread packages/cli/src/lib/custom-headers.ts Resolved

@BYK BYK left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd love to avoid the unnecessary serialize->deserialize dance but other than that looks pretty good, thanks!

Comment thread packages/cli/src/lib/custom-headers.ts Outdated
/**
* Serialize a header map into the `SENTRY_CUSTOM_HEADERS` string format.
*
* Inverse of {@link parseCustomHeaders}: the result round-trips through it.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we not avoid the round-trip and unnecessary string serialize/deserialize waste?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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>
@JPeer264
JPeer264 merged commit c8a5ce4 into main Aug 25, 2026
31 checks passed
@JPeer264
JPeer264 deleted the jp/sdk-headers-option branch August 25, 2026 10:04

This branch was successfully deployed

1 active deployment
Preview — 8a7e94e3 Deployed Aug 25, 2026 by vercel[bot]
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants