You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Warm pinned card variants or stop advertising them #5
The README advertises pinned card variants with ?country= and ?team=, but those variants are never warmed. The plain card is served from R2; a pinned variant returns 404 from the empty cache path.
app/api/card-image/[username]/route.tsx:28-33 builds the cache key from the lowercased login plus the country and team query values. app/api/cache-image/route.ts:18-19 accepts only a login and writes cardpng:v10:${login}::, with empty variant fields. components/WarmOnView.tsx:47-55 sends only kind=card&login=...; app/[username]/page.tsx:316 does not pass the current country or team.
The browser does render the correct variant on the page. The bytes simply never reach the key the image route reads.
Expected behavior
Warm the exact variant currently displayed, or stop advertising variants that cannot be cached. If the variant is supported, pass country and team through WarmOnView and cache-image, build the same key in both places, and keep the plain key for the default view.
Taking this one. Reproduced on current main: /api/cache-image writes cardpng:v10:<login>:: for every card warm, while /api/card-image/[username] reads ...:<country>:<team> for pinned variants — so the warm write lands in a key no variant request reads. Root cause is the duplicated key construction; fix is a shared normalising key helper passed through WarmOnView. PR will come from my fork.
components/WarmOnView.tsx:64-67 only sends kind=card&login=..., and app/[username]/page.tsx:316 passes nothing else
So the warm write lands in a key no variant read can hit. Agreed that a shared key helper is the right shape.
Two points need clarity before the PR, because they decide whether the helper actually closes the gap:
Both sides must call it. If only cache-image normalises, write and read can still diverge on case — pickFlag() returns lowercase codes (nl) and pickTeam() uppercases codes (FER), while the OG route currently drops raw query strings into the key. Which value is canonical: the raw query, or the resolved flag/team? My preference is the resolved values, so ?country=NL and ?country=nl share one object and an invalid override doesn't mint a variant key holding plain bytes.
Team input. The issue's probe uses ?team=ferrari, but pickTeam() only accepts codes (FER, RBR, …) and returns null for a full name. Are we fixing code-only pins, or does the parser need to accept names too? Either way an invalid override should fall back to the plain key rather than create a variant key.
Please also cover the acceptance list in the PR: tests for the default key and both pinned keys, plus a check that warming a variant does not evict the plain object. And app/[username]/page.tsx will need to hand the current country/team to WarmOnView — if you'd rather leave the page alone, say why, because the displayed variant would still go unwarmed.
I'll keep an eye out for the PR from your fork.
Initial draft by me; final message written with Hermes Agent.
Answering your two points before the PR (grant is still off on my side, so the branch is committed locally but not pushed yet):
Canonical value = resolved values. Both routes now call the same cardCacheKey() helper, which runs normalizeCountry() and pickTeam() on both the read and write side. So ?country=NL and ?country=nl share the nl object, and an invalid override normalises to empty instead of minting a variant key. The page passes the explicit query values (sp.country / sp.team) rather than the resolved display flag or cookie prefs — the embed read path only knows the query string, so passing displayFlag would warm :nl:FER for a ?team=FER visit while that embed reads ::FER. An independent review caught exactly that gap and it is fixed in the branch.
Team input stays code-only. I did not widen pickTeam() to accept full names. TeamPicker writes codes (FER, RBR, ...), so ?team=ferrari now normalises to the plain key rather than creating a variant that holds plain bytes. If you want name aliases too, that is a small follow-up in pickTeam(), but it changes the parser rather than the cache contract, so I kept it out of this fix.
Acceptance coverage in tests/card-variant-warm.test.ts: default/plain key, pinned flag+team, raw-vs-normalised parity, team-only parity, no-query parity, and plain vs pinned remaining distinct objects. Live probe on current production still returns 404 / x-og-cache: miss-empty for /torvalds.png?country=nl&team=FER; the plain card is r2-hit. The PR body will carry the same evidence and disclosure.
PR is up: #17 — from my fork, branch bot/fix-pinned-card-variant-warm-issue-5, head ca900ea. It applies the shared normalising key helper on both read and write paths, passes explicit query variants through WarmOnView, and adds the route-parity tests discussed above. Locally: 47/47 tests, tsc clean, lint 0 errors, build green. CI on the PR had not reported checks when I opened it.
Activity
saswatdutta1310 commentedon Nov 26, 2026
Taking this one. Reproduced on current main:
/api/cache-imagewritescardpng:v10:<login>::for every card warm, while/api/card-image/[username]reads...:<country>:<team>for pinned variants — so the warm write lands in a key no variant request reads. Root cause is the duplicated key construction; fix is a shared normalising key helper passed through WarmOnView. PR will come from my fork.LangerSword commentedon Nov 26, 2026
Thanks for taking this — your read matches what I see on current
main:app/api/cache-image/route.ts:18writescardpng:v10:${login}::app/api/card-image/[username]/route.tsx:30readscardpng:v10:${lower}:${override}:${teamCode}components/WarmOnView.tsx:64-67only sendskind=card&login=..., andapp/[username]/page.tsx:316passes nothing elseSo the warm write lands in a key no variant read can hit. Agreed that a shared key helper is the right shape.
Two points need clarity before the PR, because they decide whether the helper actually closes the gap:
Both sides must call it. If only
cache-imagenormalises, write and read can still diverge on case —pickFlag()returns lowercase codes (nl) andpickTeam()uppercases codes (FER), while the OG route currently drops raw query strings into the key. Which value is canonical: the raw query, or the resolved flag/team? My preference is the resolved values, so?country=NLand?country=nlshare one object and an invalid override doesn't mint a variant key holding plain bytes.Team input. The issue's probe uses
?team=ferrari, butpickTeam()only accepts codes (FER,RBR, …) and returnsnullfor a full name. Are we fixing code-only pins, or does the parser need to accept names too? Either way an invalid override should fall back to the plain key rather than create a variant key.Please also cover the acceptance list in the PR: tests for the default key and both pinned keys, plus a check that warming a variant does not evict the plain object. And
app/[username]/page.tsxwill need to hand the currentcountry/teamtoWarmOnView— if you'd rather leave the page alone, say why, because the displayed variant would still go unwarmed.I'll keep an eye out for the PR from your fork.
Initial draft by me; final message written with Hermes Agent.
saswatdutta1310 commentedon Nov 26, 2026
Answering your two points before the PR (grant is still off on my side, so the branch is committed locally but not pushed yet):
Canonical value = resolved values. Both routes now call the same
cardCacheKey()helper, which runsnormalizeCountry()andpickTeam()on both the read and write side. So?country=NLand?country=nlshare thenlobject, and an invalid override normalises to empty instead of minting a variant key. The page passes the explicit query values (sp.country/sp.team) rather than the resolved display flag or cookie prefs — the embed read path only knows the query string, so passingdisplayFlagwould warm:nl:FERfor a?team=FERvisit while that embed reads::FER. An independent review caught exactly that gap and it is fixed in the branch.Team input stays code-only. I did not widen
pickTeam()to accept full names.TeamPickerwrites codes (FER,RBR, ...), so?team=ferrarinow normalises to the plain key rather than creating a variant that holds plain bytes. If you want name aliases too, that is a small follow-up inpickTeam(), but it changes the parser rather than the cache contract, so I kept it out of this fix.Acceptance coverage in
tests/card-variant-warm.test.ts: default/plain key, pinned flag+team, raw-vs-normalised parity, team-only parity, no-query parity, and plain vs pinned remaining distinct objects. Live probe on current production still returns 404 /x-og-cache: miss-emptyfor/torvalds.png?country=nl&team=FER; the plain card isr2-hit. The PR body will carry the same evidence and disclosure.LangerSword commentedon Nov 26, 2026
Assigned @saswatdutta1310 to #5
All the best!
saswatdutta1310 commentedon Nov 26, 2026
PR is up: #17 — from my fork, branch
bot/fix-pinned-card-variant-warm-issue-5, headca900ea. It applies the shared normalising key helper on both read and write paths, passes explicit query variants throughWarmOnView, and adds the route-parity tests discussed above. Locally: 47/47 tests, tsc clean, lint 0 errors, build green. CI on the PR had not reported checks when I opened it.