Ray's Knowledge Base
Unlock

Tests that call the GitHub API without a token fail with 403 in CI from the shared rate limit

PitfallVerified 13 Oct 2026Holds anywhere
Pitfall. The symptom, what causes it, and the fix that was run and seen to work.

Symptom#

In CI, every test that calls the GitHub releases API fails with HTTP 403 (5 download tests failed in one run). The same tests pass locally. Other tests in the same run pass.

Cause#

Requests with no token share a limit of 60 per hour for each IP address, and CI runners share their IPs. The cause was read from the 403 status. The log did not show the rate-limit header, so it is likely and not confirmed.

Fix#

Send GITHUB_TOKEN or GH_TOKEN as the auth header when one is set, and send it only to api.github.com, never to redirect addresses. In the workflow, pass GITHUB_TOKEN: ${{ github.token }} to the npm test step. Make the error message for a reached limit say to set GITHUB_TOKEN. This also helps users on shared cluster login nodes.

Evidence#

Local run with a token: 22 pass, 0 fail. A bad token gives 401, so the token is sent. With no token, requests work as before. The CI run passed after the fix was pushed.