Conversation
Apple can respond to /appleauth/auth/signin/complete with an HTML
error page instead of JSON when it rejects credentials (e.g. a
locked account). srpLogin unconditionally decoded the body as
SignInResponse before looking at the HTTP status code, so a non-JSON
body threw NetworkError.decoding with Foundation's raw DecodingError
text ("Unexpected character '<' around line 1, column 1.") instead of
a readable AuthenticationError.
Decode is now best-effort, and the HTTP status code drives branching
regardless of whether the body parsed. When it doesn't parse, a
truncated preview of the raw body is used as the error message
instead.
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
zakis5
marked this pull request as ready for review
September 22, 2026 17:11
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.
Why
When trying to install a different version of xcode from xcodes CLI, i got this error:
Summary
srpLogindecoded the sign-in response body asSignInResponsebefore checking the HTTP status code. When Apple rejects credentials (e.g. a locked account) it can return an HTML error page instead of JSON, so decoding threwNetworkError.decodingwith Foundation's rawDecodingErrortext instead of a readable error. This is whatxcodes installusers see as:Decoding is now best-effort; the HTTP status code drives branching regardless of whether the body parsed as JSON, and a truncated preview of the raw body is used as the error message when it doesn't parse.
Test plan
testSrpLoginThrowsAccountLockedWhenAppleRejectsCredentialsWithJSON— baseline case, JSON error body still maps toAuthenticationError.accountLocked.testSrpLoginThrowsDescriptiveAccountLockedErrorWhenAppleRejectsCredentialsWithHTML— reproduces the reported bug (403 + HTML body) and asserts a readableaccountLockederror instead of a rawDecodingError.swift testpasses (35/35, 1 skipped live-network test).xcodesCLI (XcodesOrg/xcodes) against this branch locally and ranxcodes updateto confirm the real login flow still works end-to-end.