fix(oauth): Prevent validation errors from orphaned client tokens#20072
Open
vpomerleau wants to merge 1 commit intomainfrom
Open
fix(oauth): Prevent validation errors from orphaned client tokens#20072vpomerleau wants to merge 1 commit intomainfrom
vpomerleau wants to merge 1 commit intomainfrom
Conversation
dschom
reviewed
Feb 17, 2026
dschom
reviewed
Feb 17, 2026
6060a17 to
db71e40
Compare
vpomerleau
commented
Feb 18, 2026
db71e40 to
6960f36
Compare
There was a problem hiding this comment.
Pull request overview
This PR addresses Joi validation failures in connected-services responses when OAuth client tokens become orphaned and client_name comes back as undefined from a left join, by normalizing the display name and adding a regression test.
Changes:
- Coerce
oauthClient.client_nametonull(instead of propagatingundefined) when populatingAttachedClient.name. - Return a copy from
getDefaultClientFields()to avoid sharing the defaults object. - Add a regression test covering
undefined client_namehandling.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| packages/fxa-shared/connected-services/factories.ts | Normalizes missing OAuth client names to null; returns cloned defaults for client field initialization. |
| packages/fxa-shared/test/connected-services/factories.ts | Adds regression test ensuring undefined client_name is coerced to null. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
…nt tokens Because: * Sentry showed ValidationError: "[0].name" is required * OAuth token queries use LEFT OUTER JOIN with clients table * When a client is deleted but tokens remain (orphaned), the JOIN returns NULL * This may be converted to undefined, which fails Joi validation This commit: * Add nullish coalescing in factories.ts when merging OAuth and device client names; Joi validation explicitily allows null * Fix shared reference bug in getDefaultClientFields() to return copy of defaults * Add regression test for undefined client_name and device name handling Closes #FXA-13132
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.
Because
This pull request
Issue that this pull request solves
Closes: FXA-13132
Checklist
Put an
xin the boxes that applyScreenshots (Optional)
Please attach the screenshots of the changes made in case of change in user interface.
Other information (Optional)
Any other information that is important to this pull request.