fix: retry GrandSlam auth on 5xx errors and prevent plist format crash - #1
fix: retry GrandSlam auth on 5xx errors and prevent plist format crash#1BananaOnGitHub wants to merge 1 commit into
Conversation
- Add GrandSlamTransport with ephemeral connection pooling to prevent persistent edge connection pinning - Retry HTTP 5xx responses with exponential backoff on auth operations (init, complete, apptokens) - Throw explicit NSURLErrorBadServerResponse instead of passing HTML error bodies to PropertyListSerialization (causing NSCocoaErrorDomain 3840) - Add GrandSlamTransportTests covering success, backoff retries, server error bounds, and cancellation
|
this PR is not required, the issue is already resolved. fyi, URL session doesn't need to be created adhoc like it was done in this PR, and not all network issues need a retry and timeout etc. If using AI please be responsible to read the code and confirm once that all changes are really addressing the problem (to be specific which problem coz a brute forcing is not a solution) and are performant. if u try using latest nightly and still face any issues let us know in sidestore's issues. |
|
Fixes the recurring "The data couldn't be read because it isn't in the correct format" (
NSCocoaErrorDomaincode3840) error encountered during Apple ID login and app refresh operations.This is currently affecting users in the wild, with recent reports of login/refresh failures:
NSCocoaErrorDomain 3840/Encountered unknown tag html on line 1failure in the upstream AltStore stack.A previous detailed SideStore report, SideStore/SideStore#1446, captured the GrandSlam sequence directly:
initandcompletesucceeded with HTTP 200, while the subsequentapptokensrequest returned an HTML503 Service Temporarily Unavailableresponse.Cause
When communicating with Apple's GrandSlam authentication endpoint (
gsa.apple.com/grandslam/GsService2) duringinit,complete, andapptokensexchanges:503 Service Temporarily Unavailableresponses with HTML bodies.sendAuthenticationRequestpassed the response directly toPropertyListSerialization.propertyList(from: data, ...).PropertyListSerializationfails with Cocoa error3840, producing the misleading user-facing error "The data couldn't be read because it isn't in the correct format."This failure mode has been observed directly in SideStore/SideStore#1446 and is consistent with the currently open
3840/ HTML-response reports above.Solution
GrandSlamTransport: Introduced an isolated transport enum specifically for the three GrandSlam auth operations (init,complete,apptokens).URLSessionper attempt (reloadIgnoringLocalCacheData, no URL cache, no cookie/credential storage) to avoid persistent connection pinning to failing edge nodes.NSURLErrorBadServerResponsedescribing the HTTP status instead of passing HTML to the plist parser. Account credentials/bodies are not leaked.GrandSlamTransportTestscovering successful plist responses, 503 retry recovery, exhausted 5xx errors, non-retried 4xx errors, transport errors, and cancellation during backoff.Result
For transient GrandSlam 5xx responses, SideSign now retries the request over a fresh connection instead of immediately attempting to parse an HTML error page as a property list.
If Apple's service recovers on a subsequent attempt, authentication continues normally. If the retry budget is exhausted, callers receive a meaningful server-response error rather than the unrelated
NSCocoaErrorDomain 3840plist parsing error.