Repository navigation
http: throw on unsuccessful responses - #246
Merged
Merged
Conversation
Apple's endpoints report failures as HTML error pages, which callers passed straight to a PropertyListDecoder, so a 503 surfaced as "the given data was not a valid property list". Ref xtool-org#243.
Member
|
Cheers 🙌 |
3 of 4 tasks
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.
Ref #243.
makeRequestnever inspectedresponse.status, so a non-2xx body wasreturned as if it had succeeded. Every caller decodes that body as a property list
or JSON, so Apple answering with an HTML error page surfaced as:
which says nothing about what actually happened. In the case that prompted #243, GSA
was returning
503 Service Temporarily Unavailablefor theapptokensoperation. Itnow reads:
Notes
text/htmlandtext/plain,i.e. gateway error pages. Bodies from the auth endpoints can carry account details
(the 2FA requests use
Accept: application/x-buddyml), and errors get printedverbatim in places such as
DevCommand.swift:164, so those are left out. It alsoavoids emitting replacement characters for binary bodies.
XADIProvider's download no longerprints
100%immediately before failing.collect(_:onProgress:)so there is a single exit point.Buffer pre-sizing and progress reporting are unchanged.
SDKBuilderalready does this check by hand onsend(), so it is unaffected.Behaviour changes worth a look
XADIProviderwrites the Apple Music APK download straight to disk; a faileddownload now throws instead of leaving a corrupt
applemusic.apk.GrandSlamTrustedDeviceRequest,GrandSlamSMSAuthRequest,GrandSlamValidateRequest) use no-op decoders, so a rejected request is currentlydiscarded and xtool goes on to prompt for a code that was never sent — the symptom
in xtool setup with hardware key #235. Those now fail loudly.
Two things I left alone
GrandSlamTwoFactorAuthenticateOperation.swift:47catchesGrandSlamOperationErrorwith code
-21669to report an incorrect verification code, but that error is onlythrown by
GrandSlamOperationDecoder, which the validate requests do not use, so thecatch is unreachable. With this change a wrong code surfaces as a raw HTTP error
instead. Mapping the status back to
incorrectVerificationCodeseemed like your call,since I do not know what GSA returns for a bad code.
would pre-empt it. I could not find one —
developerservices2returns HTTP 200 withresultCode/userStringin the body, which is untouched here.Built and linted on Linux (
swift build --product xtool,make lint: 0 violations).