hotfix(citable): stop poisoning aggregator cache with all-draft set - #610
Merged
Conversation
Fixes /api/citable returning all benchmarks as draft when /api/stat/<slug> for the same bench returns live data. Root cause: loadAllBenchmarksCached returned an all-draft set whenever per-bench fetches threw at cold start, and the cache then served that poisoned set for the rest of the 60s revalidate window. Restores the throw-on-all-draft behaviour at the cache boundary so unstable_cache keeps the previous good value during a Prom blackout. Adds an AllBenchmarksDraftError sentinel and a getBenchmarksSafe wrapper. Call sites split: - API endpoints and feeds (citable, llm-context, llms.txt, rss.xml) catch the sentinel and return 503 with retry-after, so downstream consumers do not treat the placeholder set as ground truth. - Pages (home, benchmarks index, bench slug, category, mcp page) and shared loaders (chains, providers) use getBenchmarksSafe which catches the sentinel and renders draft placeholders so the build and the page render still succeed. - Sitemap already uses safeLoad which catches and falls back. Cache key bumped from v12 to v13 to flush any poisoned snapshot already stored in Upstash KV. Adds a regression test that asserts the aggregator never returns a stable all-draft list. Extracted aggregateBenchmarks as a pure function so the test does not need Prometheus or unstable_cache.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Cherry-pick of #607 to main as a hotfix.
Fixes /api/citable returning all benchmarks as draft when /api/stat/
for the same bench returns live data. Root cause: loadAllBenchmarksCached
was returning an all-draft set whenever per-bench fetches threw at cold
start, and the cache then served that poisoned set for the rest of the
revalidate window.
This change restores the throw-on-all-draft behaviour at the cache
boundary so unstable_cache keeps the previous good value during a Prom
blackout. The known call sites are wrapped explicitly: API endpoints and
feeds (citable, llm-context, llms.txt, rss.xml) return 503 with a
retry-after hint, pages and shared loaders (home, benchmarks index,
bench slug, mcp page, chains, providers) use a new getBenchmarksSafe
wrapper that renders draft placeholders, and the sitemap already uses
safeLoad which catches and falls back.
Cache key bumped from v12 to v13 to flush any poisoned snapshot already
stored in Upstash KV.
Adds a regression test that asserts the aggregator never returns a
stable all-draft list.
Cherry-pick notes
Some conflicts resolved against main's slightly older surface:
from the cherry-pick.
the existing field set, only added the AllBenchmarksDraftError import
and the try/catch + 503.
surface, only switched the loader to getBenchmarksSafe.
Test plan