Skip to content

fix: accept nullable user fields in OAuth token response#470

Merged
BYK merged 1 commit intomainfrom
fix/oauth-nullable-user-name
Mar 19, 2026
Merged

fix: accept nullable user fields in OAuth token response#470
BYK merged 1 commit intomainfrom
fix/oauth-nullable-user-name

Conversation

@BYK
Copy link
Member

@BYK BYK commented Mar 19, 2026

The Sentry API can return null for user.name in the OAuth token response. The Zod schema had name: z.string() which rejected null, causing safeParse() to fail and login to throw 'Unexpected response from token endpoint'.

Changes

  • Make name and email nullable in TokenResponseSchema (root cause)
  • Make name nullish in SentryUserSchema for consistency
  • Convert null → undefined at the UserInfo/LoginResult boundary in interactive-login.ts, auth/login.ts, and auth/whoami.ts
  • Add focused schema tests for nullable user fields

Closes #468

@github-actions
Copy link
Contributor

github-actions bot commented Mar 19, 2026

Semver Impact of This PR

🟢 Patch (bug fixes)

📋 Changelog Preview

This is how your changes will appear in the changelog.
Entries from this PR are highlighted with a left border (blockquote style).


Bug Fixes 🐛

  • Accept nullable user fields in OAuth token response by BYK in #470

Internal Changes 🔧

  • Regenerate skill files by github-actions[bot] in 77603fc3

🤖 This preview updates automatically when you update the PR.

@BYK BYK marked this pull request as ready for review March 19, 2026 10:53
@github-actions
Copy link
Contributor

github-actions bot commented Mar 19, 2026

Codecov Results 📊

126 passed | Total: 126 | 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 1034 uncovered lines.
✅ Project coverage is 95.7%. Comparing base (base) to head (head).

Files with missing lines (2)
File Patch % Lines
interactive-login.ts 92.16% ⚠️ 8 Missing
login.ts 98.46% ⚠️ 2 Missing
Coverage diff
@@            Coverage Diff             @@
##          main       #PR       +/-##
==========================================
+ Coverage    95.35%    95.70%    +0.35%
==========================================
  Files          177       177         —
  Lines        24086     24065       -21
  Branches         0         0         —
==========================================
+ Hits         22965     23031       +66
- Misses        1121      1034       -87
- Partials         0         0         —

Generated by Codecov Action

@BYK BYK force-pushed the fix/oauth-nullable-user-name branch 2 times, most recently from f2b2554 to 4061009 Compare March 19, 2026 11:22
Copy link

@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.

The Sentry API can return `null` for `user.name` in the OAuth token
response. The Zod schema had `name: z.string()` which rejected null,
causing `safeParse()` to fail and login to throw 'Unexpected response
from token endpoint'.

- Make `name` and `email` nullable in `TokenResponseSchema`
- Make `name` nullish in `SentryUserSchema` for consistency
- Convert null → undefined at the UserInfo/LoginResult boundary
- Add focused schema tests for nullable user fields

Closes #468
@BYK BYK force-pushed the fix/oauth-nullable-user-name branch from 4061009 to 177e049 Compare March 19, 2026 11:29
@BYK BYK merged commit 28ab647 into main Mar 19, 2026
22 checks passed
@BYK BYK deleted the fix/oauth-nullable-user-name branch March 19, 2026 11:39
@gwillem
Copy link

gwillem commented Mar 19, 2026

Thanks for the amazing fast fix!

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.

bug: auth login fails with 'Unexpected response from token endpoint' despite receiving valid token

2 participants