Skip to content

ci: keep the token across GitHub API redirects - #2234

Merged
Benoît Cortier (CBenoit) merged 3 commits into
masterfrom
cbenoit-ci-flakes-oracle-redirect
Dec 2, 2026
Merged

Benoît Cortier (CBenoit) merged 3 commits into
masterfrom
cbenoit-ci-flakes-oracle-redirect

Conversation

@CBenoit

@CBenoit Benoît Cortier (CBenoit) commented Dec 1, 2026 •

Copy link
Copy Markdown
Member

The oracle marker check intermittently failed with "API rate limit exceeded for " although it sends a token. GitHub answers a request for a renamed repository, such as Devolutions/now-proto, with a redirect, and PowerShell drops the Authorization header when following it, so the request counted against the unauthenticated limit that GitHub-hosted runners share, and a private renamed repository would have been reported unreadable instead of checked.

The check now follows redirects itself, with the token, and only within api.github.com, the one host given the token; a redirect anywhere else is not followed, and its status stops the check. Tests check that the API call carries the token, keeps it on a redirect within api.github.com, and stops on one elsewhere.

The oracle marker check intermittently failed with "API rate limit
exceeded for <runner IP>" although it sends a token. GitHub answers a
request for a renamed repository, such as Devolutions/now-proto, with a
redirect, and PowerShell drops the Authorization header when following
it, so the request counted against the unauthenticated limit that
GitHub-hosted runners share, and a private renamed repository would have
been reported unreadable instead of checked.

The token is now kept on redirects, which stay on api.github.com.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Copilot AI adaptive review requested due to automatic review settings December 1, 2026 16:13
@CBenoit

Benoît Cortier (CBenoit) commented Dec 1, 2026 •

Copy link
Copy Markdown
Member Author

Evidence: "Check oracle markers" failed with GitHub API repos/Devolutions/now-proto returned 403: API rate limit exceeded for <IP> in 43255351249 (master), 44352533833 and 42084469216, each with GH_TOKEN set. repos/Devolutions/now-proto answers 301 to repositories/898498617.

Local check with a valid token against repos/Devolutions/now-proto: following the redirect with PowerShell's default handling, the response carries X-RateLimit-Limit: 60 (unauthenticated); the final version follows it with the token and reads Devolutions/now-libraries, while repos/Devolutions/devolutions-gateway/tarball/master returns its 302 to codeload unfollowed. Per the UNTESTED note, the full check on this branch: valid token passes, invalid token fails with 401, no token passes with the two private Devolutions/RDM pins syntax-checked only.

Not fixed here: 46488827382 and 46489939261 failed with API rate limit exceeded for user ID 31221910, the shared DEVOLUTIONSBOT_TOKEN account's own quota being exhausted. The intent requires a rate limit to fail the check rather than skip, so that needs a token with its own quota, not a code change.

Lines changed: production code 0; tests +35; other files (CI script) +20/−4.

Note

LLM-assisted content (no human feedback).

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟡 Changes recommended

The tests bypass the default GitHub API implementation, so removing authorization preservation across redirects could reintroduce rate-limit failures without failing the suite.

1 open issue
What changed in this PR

Keeps oracle-marker checks authenticated across redirects for renamed GitHub repositories, avoiding shared anonymous rate limits and preserving access to private repositories.

Changes:

  • Add -PreserveAuthorizationOnRedirect to the GitHub API request.
  • Extend the UNTESTED comment with a manual check for renamed repositories.
File Description
ci/​check-oracle-markers.ps1 Preserve authorization across redirects and update manual verification comments.

Review effort: Max (adaptive)

Comment thread ci/check-oracle-markers.ps1 Resolved
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Copilot AI adaptive review requested due to automatic review settings December 1, 2026 19:51

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟡 Changes recommended

Automatic redirects can expose the bearer token to hosts other than api.github.com, including codeload.github.com via an accepted tarball path.

1 open issue
1 resolved since last review

Review effort: Max (adaptive)

Comment thread ci/check-oracle-markers.ps1 Resolved
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Copilot AI adaptive review requested due to automatic review settings December 1, 2026 22:34

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟡 Changes recommended

The HTTPS-only redirect guard and five-redirect cap lack tests or documented verification, so regressions could expose authorization tokens or permit unbounded redirect loops.

2 open issues
1 resolved since last review

Review effort: Max (adaptive)

# private repository, so redirects are followed here, and only within api.github.com, the one host given the token.
# A redirect anywhere else is returned as is, and its status then stops the check.
$Uri = [uri] "https://api.github.com/$Endpoint"
for ($Redirects = 0; $true; $Redirects++) {
Comment on lines +31 to +33
# GitHub redirects a request for a renamed repository to its new API path.
# Without the token, it would count against the runner's shared unauthenticated rate limit and could not read a
# private repository, so redirects are followed here, and only within api.github.com, the one host given the token.
@CBenoit
Benoît Cortier (CBenoit) merged commit 62207e4 into master Dec 2, 2026
152 of 166 checks passed
@CBenoit
Benoît Cortier (CBenoit) deleted the cbenoit-ci-flakes-oracle-redirect branch December 2, 2026 08:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants