Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Better Handling of Apple Unauthorized errors #249

Conversation

dmytro-kasianchuk-doordash
Copy link
Contributor

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:

  1. Attempts to catch unauthorized redirect and throw error
  2. Adds a descriptive message when this error is thrown
  3. Prevents retries in case of 403. Retrying won't help, so it's better to terminate early

How to test:

  1. In the XcodeInstaller.swift replace all instances of sessionService.loginIfNeeded() with Promise()
  2. xcodes signout
  3. Try to download e.g. xcodes install 14.0

Before 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

tabs

added comment

revert
@dmytro-kasianchuk-doordash dmytro-kasianchuk-doordash force-pushed the dmytro-kasianchuk-doordash/handle-unauthorized-errors branch from feacb66 to 7805fba Compare November 22, 2022 21:40
@MattKiazyk MattKiazyk added the enhancement New feature or request label Feb 11, 2023
Copy link
Contributor

@MattKiazyk MattKiazyk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

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!

@MattKiazyk MattKiazyk changed the title Handle Unauthorized errors Better Handling of Apple Unauthorized errors Feb 11, 2023
@MattKiazyk MattKiazyk merged commit 4a37580 into XcodesOrg:main Feb 11, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants