Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
Improves auth-server response-validation diagnostics in Sentry while redacting response values.
Changes:
- Flattens nested Joi validation details and normalizes array indexes.
- Adds sanitized Sentry context, messages, and fingerprints.
- Expands validation-reporting tests.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
packages/fxa-auth-server/lib/server.js |
Implements flattened, redacted Sentry reporting. |
packages/fxa-auth-server/lib/server.in.spec.ts |
Tests reporting, fingerprinting, and redaction. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Comment on lines
+75
to
+78
| leaves.set(`${path}:${detail.type}`, { | ||
| path, | ||
| type: detail.type, | ||
| message: redactValue(detail.message, detail.context?.value), |
## Because - `flattenValidationDetails` keyed its dedup map on path and Joi type alone. Two different constraints on one path overwrote each other. - `accessToken` is an `alternatives()` of two string patterns, so both branches report `string.pattern.base` on the same path. Only the second one survived, and the fingerprint could not tell a hex-token failure from a JWT failure. - So the grouping problem this PR set out to fix came back one level down. ## This pull request - Adds a `constraint` field to each flattened leaf, taken from `detail.context.regex.source`. - Keys the dedup map and the Sentry fingerprint on `path:type:constraint`, so the two patterns stay apart. - Builds the spec fixture from the production `accessToken` validator in `lib/oauth/validators.js`, so the test covers the real colliding patterns. ## Issue that this pull request solves Closes: https://mozilla-hub.atlassian.net/browse/FXA-14395
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
flattenValidationDetailskeyed its dedup map on path and Joi type alone. Two different constraints on one path overwrote each other.accessTokenis analternatives()of two string patterns, so both branches reportstring.pattern.baseon the same path. Only the second one survived, and the fingerprint could not tell a hex-token failure from a JWT failure.This pull request
constraintfield to each flattened leaf, taken fromdetail.context.regex.source.path:type:constraint, so the two patterns stay apart.accessTokenvalidator inlib/oauth/validators.js, so the test covers the real colliding patterns.Issue that this pull request solves
Closes: https://mozilla-hub.atlassian.net/browse/FXA-14395
Checklist
Put an
xin the boxes that applyHow to review (Optional)
flattenValidationDetailsinpackages/fxa-auth-server/lib/server.js.server.js, thenserver.in.spec.ts.failActionandredactValuehave zero diff, and the array-index collapse still groupsitems[0]anditems[3]as one entry.Screenshots (Optional)
Other information (Optional)
?? detail.context?.nameas a second fallback. I left it out. In Joi,nameappears only onstring.pattern.name, and that context always carriesregextoo (joi/lib/types/string.js:571), so the branch never runs. I will add it back if you want it as a guard.string.max(3)againststring.max(5)on one path.context.limitis the obvious discriminator, but it can be aJoi.ref()that resolves from the response payload, which would put a value in Sentry. That needs its own ticket.npx jest packages/fxa-auth-server/lib/server.in.spec.ts: 63 passed, 0 failed.npx nx lint fxa-auth-server: clean.