feat(auth): replace WAF "unexpected error" with more meaningful copy#20677
Conversation
There was a problem hiding this comment.
Pull request overview
This PR updates fxa-auth-client request error handling to detect WAF-blocked responses that return non-JSON bodies (notably 406/429) and map them to known FxA errnos so downstream UIs can render localized, actionable error messages instead of a generic “Unexpected error”.
Changes:
- Add special-case handling for non-JSON 406/429 responses to synthesize known errnos (114/125) and emit a targeted Sentry message.
- Extend the auth-client test suite with coverage for WAF-blocked non-JSON bodies and for preserving existing behavior in other non-JSON failure cases.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| packages/fxa-auth-client/lib/client.ts | Adds WAF detection on JSON parse failure for 406/429 and maps to known errnos with Sentry tagging. |
| packages/fxa-auth-client/test/client.ts | Adds/updates tests to validate synthesized errno behavior and Sentry capture for WAF-blocked responses. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
LZoog
left a comment
There was a problem hiding this comment.
I didn't test this locally by trying to throw one of these errors, but code LGTM.
| throw parseError; | ||
| } | ||
| errorCaptured = true; | ||
| Sentry.captureMessage(`Auth client encountered WAF-blocked response`, { |
There was a problem hiding this comment.
Is this something we want in Sentry? Seems like it'd be nice, but also don't want it eating our tokens for something we won't ever resolve.
There was a problem hiding this comment.
Maybe we want this in statsd though? Not sure 🙂
8079949 to
2bc60e5
Compare
| } | ||
| errorCaptured = true; | ||
| throw new AuthClientError( | ||
| 'WAF blocked', |
There was a problem hiding this comment.
I don't think we need to surface "WAF'? Don't think many folks will know/care what that is. Maybe just "Request blocked"
There was a problem hiding this comment.
@vbudhram -- I believe this is internal only, for dev reviewing logs, sentry, etc. Users should see translated strings instead.
There was a problem hiding this comment.
@toufali you could add a Storybook state for this error too if it's easy to ask Claude to do it. 🤷♀️
There was a problem hiding this comment.
a9e927e to
ca25f73
Compare
ca25f73 to
ac9dba4
Compare

Because
JSON.parsefails and the UI falls back to "Unexpected error", giving devs and false-positive users no guidance.This pull request
AuthClientErrorwitherrno: 125(REQUEST_BLOCKED) for 406 anderrno: 114(THROTTLED) for 429.auth-error-125,auth-error-114-generic)Issue that this pull request solves
Closes: FXA-13612
Checklist
How to review (Optional)
packages/fxa-auth-client/lib/client.ts— the parse-failure branch inAuthClient.request().getLocalizedErrorMessageinpackages/fxa-settings/src/lib/error-utils.ts— it looks up byerrno, so 114/125 already work.Other information (Optional)
SyntaxErrorextra. They now surface as "WAF-blocked response" withstatusanderrnotags. Intentional, but worth knowing for any saved searches.