Fix stale GitHub API cache for Bazel module versions
What are you trying to accomplish?
Dependabot was reporting outdated Bazel module versions from the Central Registry (e.g., rules_python 1.7.0-rc4 instead of 1.7.0 final, released weeks earlier). GitHub API responses were being cached by intermediate proxies despite 60-second cache-age headers, causing Dependabot to miss new releases.
This PR adds Cache-Control: no-cache headers to all GitHub API requests in the Bazel RegistryClient to bypass stale caches and ensure fresh version data.
Anything you want to highlight for special attention from reviewers?
Implementation:
- Added
cache_busting_headersprivate method inRegistryClient - Applied headers to all GitHub API calls:
contents()andcommits() - Affects:
all_module_versions,get_source,get_module_bazel,get_version_release_date
Alternative approaches considered:
- ETags/conditional requests: Still relies on cache validation, doesn't solve stale proxy caches
- Query parameter cache busting: Non-standard, breaks GitHub API contracts
- Increased request frequency: Doesn't address root cause
Cache-Control: no-cache forces fresh validation while respecting GitHub's rate limits and cache infrastructure.
How will you know you've accomplished your goal?
Tests verify cache-busting headers are passed to all GitHub API calls. When deployed, Dependabot will detect new Bazel module releases immediately after they're published to the Central Registry, rather than being blocked by week-old cached responses.
Checklist
- [x] I have run the complete test suite to ensure all tests and linters pass.
- [x] I have thoroughly tested my code changes to ensure they work as expected, including adding additional tests for new functionality.
- [x] I have written clear and descriptive commit messages.
- [x] I have provided a detailed description of the changes in the pull request, including the problem it addresses, how it fixes the problem, and any relevant details about the implementation.
- [x] I have ensured that the code is well-documented and easy to understand.
Original prompt
This section details on the original issue you should resolve
<issue_title>Dependabot producing incorrect results from stale cache of api.github.com</issue_title> <issue_description>### Is there an existing issue for this?
- [x] I have searched the existing issues
Package ecosystem
bazel
Package manager version
No response
Language version
No response
Manifest location and content before the Dependabot update
https://github.com/batfish/batfish/blob/2bcba3c8f7642761831c1fc9a99b28bc2cfb6722/MODULE.bazel#L102
dependabot.yml content
https://github.com/batfish/batfish/blob/master/.github/dependabot.yml
Updated dependency
rules_python from 1.6.3 to 1.7.0-rc4
What you expected to see, versus what you actually saw
I expected to see an upgrade to rules_python-1.7.0, which was released a while ago. RELEASES
Instead, I saw that dependabot as of 2025-11-24 only sees 1.7.0-rc4 as the latest version of rules_python. It looks to me like it's incorrectly caching the result of
https://api.github.com/repos/bazelbuild/bazel-central-registry/contents/modules/rules_python-- this has only a 60s cache-age, and has returned 1.7.0-rc5 and -rc6 and a final release as well. It's weeks out of date at this point.updater | 2025/11/24 00:42:29 INFO <job_1161802626> Checking if rules_python 1.6.3 needs updating proxy | 2025/11/24 00:42:29 [299] GET [https://api.github.com:443/repos/bazelbuild/bazel-central-registry/contents/modules/rules_python](https://api.github.com/repos/bazelbuild/bazel-central-registry/contents/modules/rules_python) 2025/11/24 00:42:29 [299] * authenticating github api request with token for api.github.com proxy | 2025/11/24 00:42:29 [299] 200 [https://api.github.com:443/repos/bazelbuild/bazel-central-registry/contents/modules/rules_python](https://api.github.com/repos/bazelbuild/bazel-central-registry/contents/modules/rules_python) proxy | 2025/11/24 00:42:29 [302] GET [https://api.github.com:443/repos/bazelbuild/bazel-central-registry/contents/modules/rules_python](https://api.github.com/repos/bazelbuild/bazel-central-registry/contents/modules/rules_python) 2025/11/24 00:42:29 [302] 200 [https://api.github.com:443/repos/bazelbuild/bazel-central-registry/contents/modules/rules_python](https://api.github.com/repos/bazelbuild/bazel-central-registry/contents/modules/rules_python) (cached) proxy | 2025/11/24 00:42:29 [304] GET [https://api.github.com:443/repos/bazelbuild/bazel-central-registry/contents/modules/rules_python](https://api.github.com/repos/bazelbuild/bazel-central-registry/contents/modules/rules_python) 2025/11/24 00:42:29 [304] 200 [https://api.github.com:443/repos/bazelbuild/bazel-central-registry/contents/modules/rules_python](https://api.github.com/repos/bazelbuild/bazel-central-registry/contents/modules/rules_python) (cached) updater | 2025/11/24 00:42:29 INFO <job_1161802626> Latest version is 1.7.0-rc4 updater | 2025/11/24 00:42:29 INFO <job_1161802626> Pull request dependabot/dependabot-core#9606 already exists for rules_python with latest version 1.7.0-rc4 proxy | 2025/11/24 00:42:29 [306] POST /update_jobs/1161802626/record_ecosystem_meta 2025/11/24 00:42:29 [306] 204 /update_jobs/1161802626/record_ecosystem_meta (cached)Native package manager behavior
N/A
Images of the diff or a link to the PR, issue, or logs
https://github.com/batfish/batfish/actions/runs/19619909157/job/56178271013
Smallest manifest that reproduces the issue
No response</issue_description>
Comments on the Issue (you are @copilot in this section)
- Fixes dependabot/dependabot-core#13624
💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.
Copilot assigned agent was unable to fix, results were the same before and after the suggested fixes. Original issue wasn't just about caching, it was about both getting fresh data && correctly sorting the versions
after https://github.com/dependabot/dependabot-core/pull/13734/commits/02e06d4f5db542e22da43c354e3b532c35e60b44 it now correctly identifies the latest version:
2025/12/10 19:43:02 INFO Checking if rules_python 1.6.3 needs updating
2025/12/10 19:43:02 INFO Latest version is 1.7.0
2025/12/10 19:43:02 INFO Requirements to unlock own
2025/12/10 19:43:02 INFO Requirements update strategy
2025/12/10 19:43:02 INFO Updating rules_python from 1.6.3 to 1.7.0
cache busting can be removed