docs(core): correct why authFetch tolerates a non-JSON body - #152
Merged
Conversation
The comment named a rate-limited request as a live reason. That is fixed upstream: a 429 has answered the JSON error shape since seamless-auth-api#241, so anyone reading this now would find the stated reason no longer true and could reasonably conclude the shim can go. It cannot. A 204 still carries no body, which is what GET /magic-link/check answers while a link is unconfirmed, and the auth API sits behind a load balancer, so a 502 or a gateway timeout arrives as that proxy's HTML error page without the API being involved at all. No upstream change can prevent that one. Twenty-four call sites parse a body before checking the status, and every one of them would throw. The test that pinned the non-JSON path used a 429 as its example, which is now the one status that cannot produce it. Re-anchored on a proxy error page, which is the case that actually survives. No behaviour change.
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.
Follow-up to fells-code/seamless-auth-api#244 (closing fells-code/seamless-auth-api#241), which made a 429 answer the JSON error shape.
Answering the question that prompted this: no, the shim cannot go
The ask was to remove
makeJsonTolerantonce the 429 was fixed. It is not safe, and this PR makes the code say why instead.The comment currently reads:
The first half is no longer true. Leaving it there is worse than saying nothing, because the next reader checks the stated reason, finds it fixed, and concludes the shim is dead code.
Two reasons survive:
GET /magic-link/checkanswers 204 while a link is unconfirmed.pollMagicLinkConfirmationHandlerguards that status explicitly, but the tolerance is what makes the guard optional rather than mandatory at 24 call sites.I checked all 24
.json()call sites in core. Every one parses a body before checking the status, so any of them would throw on either case. After the 429 fix, every response the API itself produces is JSON, and the API's only 204s are both inpollMagicLinkConfirmation, so reason 1 is narrow. Reason 2 is not, and is outside anyone's control here.What changed
No behaviour change.
makeJsonTolerantis untouched and no changeset is needed.Verification
pnpm buildclean,pnpm testat the workspace root: core 231, express 154, fastify 48, all passing.