Fix GitHub API rate limiting in cli-tests #2731
Merged
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.
Problem
The cli-tests on the
mainbranch have been failing intermittently in GitHub Actions since at least October 7, 2025, due to GitHub API rate limiting when Nix attempts to fetch nixpkgs metadata.Error Message
Despite having
GITHUB_TOKENconfigured in bothNIX_CONFIGenvironment variable and~/.config/nix/nix.conf, the tests were still hitting unauthenticated rate limits.Root Cause
On macOS runners, the Nix daemon:
/etc/nix/nix.confinstead of the user's~/.config/nix/nix.confThis meant that while
nix show-configshowed the access token was configured, the daemon wasn't actually using it when making GitHub API requests.Solution
This PR implements a two-pronged approach:
1. Configure Nix Daemon Properly (Primary Fix)
/etc/nix/nix.confwith the GitHub tokenauto-nix-installjob, configure AFTER Nix is installed (not before)2. Pass Token via Command-Line Options (Backup)
internal/nix/command.goto pass--option access-tokens github.com=$GITHUB_TOKENin all nix commandsChanges
.github/workflows/cli-tests.yaml:/etc/nix/nix.confexists before writingauto-nix-installjob to configure Nix AFTER installation completesinternal/nix/command.go: Add GITHUB_TOKEN to nix command args as --option access-tokensDetailed Analysis
For a comprehensive diagnostic report with evidence, timeline, and alternative solutions considered, see:
CLI Tests Failure Report
Note on Reproduction
The issue is specific to GitHub Actions environment and cannot be easily reproduced locally:
This PR validates the fix directly in CI/CD where the issue occurs.
Fixes the intermittent test failures that have been occurring since October 7, 2025.