install: retry without token when authenticated requests fail#1968
Draft
install: retry without token when authenticated requests fail#1968
Conversation
Tokens from GitHub org members that haven't been SSO-authorized for the org will be rejected by SAML enforcement, causing downloads to fail. Add a download() helper that tries with the token first, then falls back to an unauthenticated request on failure. Apply the same retry logic to the git ls-remote call for prerelease detection. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This was referenced Mar 11, 2026
andyfeller
reviewed
Mar 11, 2026
Comment on lines
+47
to
+70
| # Download a file, retrying without auth on failure (e.g. SAML enforcement) | ||
| download() { | ||
| local url="$1" output="$2" | ||
| if command -v curl >/dev/null 2>&1; then | ||
| if [ ${#CURL_AUTH[@]} -gt 0 ]; then | ||
| if curl -fsSL "${CURL_AUTH[@]}" "$url" -o "$output" 2>/dev/null; then | ||
| return 0 | ||
| fi | ||
| echo "Warning: Authenticated request failed, retrying without token..." >&2 | ||
| fi | ||
| curl -fsSL "$url" -o "$output" | ||
| elif command -v wget >/dev/null 2>&1; then | ||
| if [ ${#WGET_AUTH[@]} -gt 0 ]; then | ||
| if wget -qO "$output" "${WGET_AUTH[@]}" "$url" 2>/dev/null; then | ||
| return 0 | ||
| fi | ||
| echo "Warning: Authenticated request failed, retrying without token..." >&2 | ||
| fi | ||
| wget -qO "$output" "$url" | ||
| else | ||
| echo "Error: Neither curl nor wget found. Please install one of them." >&2 | ||
| return 1 | ||
| fi | ||
| } |
Contributor
There was a problem hiding this comment.
praise: stderr messaging informing users = 🧑🍳 💋
This was referenced Mar 12, 2026
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.
Summary
When a
GITHUB_TOKENis set but belongs to a GitHub org member whose token hasn't been SSO-authorized, SAML enforcement rejects the request — causing the install to fail even though the repo is public.This adds a
download()helper that tries with the token first, then automatically retries without it on failure. The same retry logic is applied to thegit ls-remotecall used for prerelease version detection.Changes
download()helper function that:curl/wgetnot found if neither is availablecurl/wgetcalls for tarball and checksums downloads withdownload()git ls-remotefor prerelease detectionBehavior
GITHUB_TOKENset