Skip to content

fix(auth): bake public OAuth client ID as fallback in getClientId()#916

Merged
BYK merged 2 commits intomainfrom
fix/bake-oauth-client-id
May 5, 2026
Merged

fix(auth): bake public OAuth client ID as fallback in getClientId()#916
BYK merged 2 commits intomainfrom
fix/bake-oauth-client-id

Conversation

@BYK
Copy link
Copy Markdown
Member

@BYK BYK commented May 5, 2026

What

Commit the sentry.io OAuth client ID directly as DEFAULT_OAUTH_CLIENT_ID in oauth.ts, used as the final fallback in getClientId().

Why this is safe

The OAuth client ID is public by design. Device Authorization Grant (RFC 8628) is a public-client flow — there is no client secret involved. The value is already stored as a plain repo variable (vars.SENTRY_CLIENT_ID) in CI, not a secret, and has always been readable by anyone with repo access.

Why #911 was over-engineered

PR #911 addressed the same problem but introduced a separate "development" client ID, a new RELEASE_BUILD guard, an ensureSentryClientIdConfigured() function, asymmetric behaviour between build.ts and bundle.ts, and touched 10 files. The dev-vs-production distinction isn't meaningful when both IDs are equally public.

What changes

The fallback chain in getClientId() is unchanged in priority:

SENTRY_CLIENT_ID env var → SENTRY_CLIENT_ID_BUILD (build-time define) → committed default
  • Local dev against sentry.io: works out of the box, no .env.local needed
  • Self-hosted: still override via SENTRY_CLIENT_ID env var
  • Release binaries / npm bundle: still inject via SENTRY_CLIENT_ID_BUILD from SENTRY_CLIENT_ID env var at build time — no behaviour change

Closes #911

The OAuth client ID is a public value — Device Authorization Grant (RFC 8628)
uses a public-client flow with no client secret. The value is already stored
as a plain repo variable (vars.SENTRY_CLIENT_ID) in CI, not a secret.

Committing it as DEFAULT_OAUTH_CLIENT_ID eliminates the .env.local requirement
for local development against sentry.io. The priority chain is unchanged:

  SENTRY_CLIENT_ID env var → SENTRY_CLIENT_ID_BUILD (build-time) → committed default

Self-hosted users still override via SENTRY_CLIENT_ID env var; production
release builds still inject via SENTRY_CLIENT_ID_BUILD — no behaviour change
for either path.
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 5, 2026

PR Preview Action v1.8.1

QR code for preview link

🚀 View preview at
https://cli.sentry.dev/_preview/pr-916/

Built to branch gh-pages at 2026-05-05 11:44 UTC.
Preview will be ready when the GitHub Pages deployment is complete.

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 5, 2026

Codecov Results 📊

6664 passed | Total: 6664 | Pass Rate: 100% | Execution Time: 0ms

📊 Comparison with Base Branch

Metric Change
Total Tests
Passed Tests
Failed Tests
Skipped Tests

✨ No test changes detected

All tests are passing successfully.

✅ Patch coverage is 100.00%. Project has 13516 uncovered lines.
✅ Project coverage is 76.63%. Comparing base (base) to head (head).

Coverage diff
@@            Coverage Diff             @@
##          main       #PR       +/-##
==========================================
+ Coverage    76.63%    76.63%        —%
==========================================
  Files          303       303         —
  Lines        57823     57823         —
  Branches         0         0         —
==========================================
+ Hits         44307     44307         —
- Misses       13516     13516         —
- Partials         0         0         —

Generated by Codecov Action

Copy link
Copy Markdown
Contributor

@cursor cursor Bot left a comment

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit d7e43e9. Configure here.

Comment thread src/lib/oauth.ts
…lways returns a value

DEFAULT_OAUTH_CLIENT_ID ensures getClientId() is never empty, making the
ConfigError guards in requestDeviceCode() and refreshAccessToken() unreachable.
Remove them and the now-unused ConfigError import.
@BYK BYK merged commit 3bd8246 into main May 5, 2026
26 checks passed
@BYK BYK deleted the fix/bake-oauth-client-id branch May 5, 2026 11:51
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