Better Handling of Apple Unauthorized errors#249
Merged
MattKiazyk merged 1 commit intoXcodesOrg:mainfrom Feb 11, 2023
Conversation
tabs added comment revert
feacb66 to
7805fba
Compare
MattKiazyk
approved these changes
Feb 11, 2023
Contributor
MattKiazyk
left a comment
There was a problem hiding this comment.
👍
I've tested locally with overriding what gets returned and things seemed to be getting caught. I wish there was a simpler way (and there probably is) but this is an awesome addition to stop the xip file being an html file!
Thanks!
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.
If a new Apple ID account doesn't accept Developer Agreement at https://developer.apple.com/ then Xcode download will fail with Unauthorized error
However, the way Apple handles unauthorized errors is by redirecting to https://developer.apple.com/unauthorized/ and happily returning 200. Therefore the only way to check for authorization is to catch this redirect. If we don't do this, then unauthorized html will be downloaded and attempted to be unxipped, so the xcodes will fail with a "corrupted xip" error.
Therefore this PR:
How to test:
XcodeInstaller.swiftreplace all instances ofsessionService.loginIfNeeded()withPromise()xcodes signoutxcodes install 14.0Before the change you would get "corrupted xip message", after the change you would get a nice descriptive message.
It's all very hacky, I would love to hear suggestions on how to improve the PR