fix(github): make githubBypassResponseCache force an own network read on both legs - #10103
Conversation
… on both legs githubBypassResponseCache is documented as an absolute force-fresh guarantee, but two legs broke it for its one production caller (fetchLiveBaseBranchAdvancedAt, the force-fresh-rebase gate's live base-tip read): 1. timeoutFetch routed the read INTO the volatile single-flight coalescer. The flag forces cls=null, which is exactly the condition that admits a URL to the coalescer, so a bypass read joined any concurrent identical in-flight read and was answered by its response -- a transient failure included -- instead of issuing its own request. Gate the volatile branch on the flag too, the same way the cache branch already is, so a bypass read goes straight to the network and never publishes itself for replay. 2. githubJsonWithHeaders' 404 unauthenticated retry dropped the flag, so on that path the read became an ordinary cacheable commit-class GET answerable from the persistent response cache (up to GITHUB_COMMIT_CACHE_TTL_SECONDS stale) for a call whose whole purpose is liveness. Propagate the flag on the retry exactly as the first request spreads it; the deliberate rateLimitAdmission omission on that retry is preserved. The volatile path is unchanged for every non-bypass read: the same URLs coalesce, the same exclusion list applies, and the coalesced/bypassed metrics are emitted as before. Closes JSONbored#10032
|
Tip ✅ LoopOver review result - approve/merge recommendedReview updated: 2026-07-31 07:17:39 UTC
Review summary Nits — 4 non-blocking
Decision drivers
Context & advisory signals — never blocks the verdict
Linked issue satisfactionAddressed Review context
Contributor next steps
Signal definitions
🧪 Chat with LoopOverAsk LoopOver a question about this PR directly in a comment — grounded only in the same cached, public-safe facts shown above, never a new claim.
Full command reference: https://loopover.ai/docs/loopover-commands 🧪 Experimental — new and may change. 🟩 Safe / merged · 🟦 Advisory · 🟨 Held for review · 🟥 Blocked / closed 💰 Earn for open-source contributions like this. Gittensor lets GitHub contributors earn for the work they already do — register to start earning →. Checked by LoopOver, a quiet PR intelligence layer for OSS maintainers.
|
|
Superagent didn't find any vulnerabilities or security issues in this PR. |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #10103 +/- ##
==========================================
+ Coverage 79.75% 80.23% +0.48%
==========================================
Files 282 284 +2
Lines 58685 60405 +1720
Branches 6878 7549 +671
==========================================
+ Hits 46804 48466 +1662
- Misses 11593 11600 +7
- Partials 288 339 +51
Flags with carried forward coverage won't be shown. Click here to find out more.
|
What & why
githubBypassResponseCacheis documented as an absolute guarantee — "Force this request to hit GitHub instead of the persistent response cache; use for freshness/security reads." Its one production caller isfetchLiveBaseBranchAdvancedAt, the force-fresh-rebase gate's live base-tip read: a base that advanced with a non-conflicting sibling commit still readsmergeable_state: "clean", so this timestamp is the only thing that forces a rebase + CI recheck before merge. It fails open, so a wrong (stale) answer merges on a stale base.Two legs broke the guarantee:
1. The read was routed into the volatile single-flight coalescer. In
timeoutFetch, setting the flag forcescls = null— which is precisely the condition that admits a URL to the coalescer:/repos/{o}/{r}/commits/{ref}is volatile-eligible, so the bypass read joined any concurrent identical in-flight read and was answered byresponseFromCached(replay, "coalesced")— never issuing its own request. That is exactly the hazard the exclusion list exists for: sharing one in-flight promise's outcome (success OR a transient failure) across independent callers. A coalesced transient failure on this read means no forced rebase.2. The 404 unauthenticated retry dropped the flag.
githubJsonWithHeadersset it on the first request and re-issued without it on the public-token 404 fallback, so the read became an ordinary cacheablecommit-class GET answerable from the persistent response cache — up toGITHUB_COMMIT_CACHE_TTL_SECONDS(default 15 min) of staleness — for a call whose entire purpose is liveness.The fix
!init?.githubBypassResponseCache). A bypass read now goes straight tofetchWithGitHubRetryand never publishes itself intoinFlightVolatileGetsfor another caller to replay.githubBypassResponseCache: truewhenever the caller setbypassResponseCache, exactly as the first request spreads it.Unchanged: the volatile path is identical for every non-bypass read (same URLs coalesce, same exclusion list, same
coalesced/bypassedmetrics); the 404 retry keeps its deliberate, documentedgithubRateLimitAdmissionomission;recordGitHubResponse's bypass/replay suppression is untouched;/commits/{ref}is not added to the exclusion list (that would de-coalesce the two hourlyresolveUpstreamCommitShareads); no cache class/TTL changes.Tests
github-client.test.ts— REGRESSION (named for the bug): two concurrent bypass reads for a volatile-eligible URL each issue their ownfetchand neither carries the replay header; a bypass read concurrent with a non-bypass leader gets its own body, not the leader's replay; and the unchanged pin — two concurrent non-bypass reads still coalesce to onefetchwithx-loopover-cache: coalesced.backfill.test.ts— abypassResponseCachecall whose first (public-token) request 404s issues a second request that also bypasses the cache (a matching stale cache entry is installed and is not replayed); and the 404 retry still sends nogithubRateLimitAdmissionheader.mainand pass with the fix.Validation
src/github/client.tsandsrc/github/backfill.tsis 100% line and branch (both arms of the new!githubBypassResponseCacheterm and thebypassResponseCache ? … : {}spread).npm run typecheckclean for these files (only the pre-existing missing-release-please-dep phantom in unrelated release tooling, present on baremain); the fullgithub-client+backfillsuites (212 tests) green.git diff --checkclean; no schema/route/env-reference/wrangler change.Closes #10032