Repository navigation
fix(card): warm pinned variants under the key the card route reads - #17
Conversation
LangerSword
left a comment
There was a problem hiding this comment.
Verdict: no blocking issue found.
Repo: LangerSword/gitone. PR #17: warm pinned card variants under the key the card route reads. Head: ca900ea.
I read all six changed files at the PR head, the issue #5 thread, and current origin/main. I ran npm test -- --run (10 files, 47 tests pass) and npx tsc --noEmit (clean). I also restored the old hardcoded write key; 4 of the 5 new tests failed, so the regression tests bite. Live checks show test passing, with eslint and rook skipped.
The shared key helper is used on both routes. Country and team normalize to the same values for raw query strings and resolved page values. Invalid team input falls back to the plain key. The tests cover the default key, pinned flag and team, raw-vs-normalised parity, team-only parity, and plain-versus-variant separation.
One product question, not a blocker: the page can resolve country and team from cookies when the query is absent (app/[username]/page.tsx:105-111). WarmOnView sends only explicit query values (components/WarmOnView.tsx:67). A visitor with a stored team who opens ?country=nl can capture an FER livery into the :nl: key, while the OG route renders that key without a team. Skip the warm when a cookie-selected variant is not represented in the query, or decide that this case is acceptable. I did not see a test for it, and I am not treating it as a merge blocker.
The PR body still leaves "Route tests added" unchecked although the file adds five tests. Tick it when convenient.
Initial draft by me; final wording written with Hermes Agent.
|
Thanks for the review and for running the sabotage check yourself. Noted: CI On the cookie-selected variant question: calling it acceptable for this PR, with the reason recorded here. That mismatch is pre-existing — before this change Also noted on the stale checkbox: all five route tests are present in |
LangerSword
left a comment
There was a problem hiding this comment.
Verdict: no_ship.
Repo: LangerSword/gitone. PR #17: warm pinned card variants under the key the card route reads. Head: ca900ea. This review supersedes my earlier COMMENT review; GitHub does not let me remove it.
What I checked: all six changed files at ca900ea, issue #5 thread, current origin/main, and the PR's three checks. I ran npm test -- --run (10 files, 47 tests pass) and npx tsc --noEmit (clean). I also restored the old hardcoded write key; 4 of the 5 new tests failed, so the regression tests bite. Live checks show test passing, with eslint and rook skipped.
Should fix before merge:
P1|components/WarmOnView.tsx:67|high|The warm URL carries only explicit query values, but the captured DOM can carry a cookie-selected variant. See the inline comment.
Non-blocking:
P3|PR body|low|The acceptance checklist leaves "Route tests added" unchecked although the file adds five tests. Tick it or explain why it stays open.
Test gap: the route tests compare key strings only. They do not compare stored bytes with what the OG route renders for that key. Add a case with a cookie-selected team plus a country-only query, and assert the warm is skipped or the stored bytes match the route's render input.
Initial draft by me; final wording written with Hermes Agent.
|
Addressed the P1 and P3 from your CHANGES_REQUESTED review. P1: added P3: ticked the route-tests box, added the cookie-skip acceptance line, and updated the verification count to 50 tests in the PR body. Fix commit |
Addressed by head 1fb0550; approving the current delta.
LangerSword
left a comment
There was a problem hiding this comment.
Verdict: ship.
Repo: LangerSword/gitone. PR #17: warm pinned card variants under the key the card route reads. Head: 1fb0550.
I reviewed the new delta at 1fb0550. It adds canWarmQueryVariant and skips the client warm when a cookie-selected variant is absent from the query. That closes the P1 from my earlier review. I reran npm test -- --run (10 files, 50 tests pass) and npx tsc --noEmit (clean). Live checks at the old head had test passing and the two bot checks skipped; I found no new check report after the push.
I found nothing outside issue #5 scope in the six changed files. The key helper is used by both routes, normalisation is shared, the plain key stays separate, and the new warm-eligibility tests cover the cookie case. The unchecked test box in the PR body is the only remaining nit and does not affect the code.
Initial draft by me; final wording written with Hermes Agent.
Closes #5
Problem
POST /api/cache-imagealways wrotecardpng:v10:<login>::, whileGET /api/card-image/[username]readscardpng:v10:<login>:<country>:<team>for pinned embeds. A visitor opening/<login>?country=nl&team=FERcaptured a real PNG and stored it in a key no variant request reads. Live probe before this fix:Root cause
The cache-key shape was duplicated in two places with different inputs; the writer had no variant fields at all. History (
532b531,1a1b3a6) shows pinned variants are deliberately separate cached objects, so this is a missing writer, not intentional design.Fix
lib/og/cardCacheKey.ts: one key builder used by both routes. It normalises country withnormalizeCountry()and team withpickTeam(), so?country=NLand?country=nlshare one object; invalid overrides and full team names collapse to the plain key instead of minting a variant holding plain bytes.app/api/card-image/[username]/route.tsxandapp/api/cache-image/route.ts: both call the shared helper.components/WarmOnView.tsx: acceptscountry/teamand sends them with the card warm request; effect dependencies updated.app/[username]/page.tsx: passes the explicit query values (sp.country,sp.team), not the resolveddisplayFlagor cookie prefs. The embed read path only knows the query string, so passingdisplayFlagwarmed:nl:FERfor a?team=FERvisit while that embed read::FER. An independent review caught this gap; it is fixed here.Acceptance coverage
?country=nl&team=FERwarms the matching variant key.Owner's two design questions from the issue thread are answered in this comment: resolved values are canonical, and team pins stay code-only.
Verification
Run locally on this branch:
The regression test was proven to fail with the old hardcoded write key restored (sabotage run: 3/3 failures), then pass with the fix.
Follow-up fix for the owner's P1 review:
canWarmQueryVariant()inlib/prefs.tsskips the client warm when a cookie supplies a variant the query does not express, so captured bytes cannot be stored under a key whose OG render differs. Three tests cover the cookie-team, cookie-country and fully-expressed cases.Disclosure
html-to-imagecapture, and CI had not run when this PR was opened. CI state will be reported from live checks, not assumed.Risk and exclusions
Low risk: key derivation only; no render tree, styling, or auth path changed. The plain
cardpng:v10:<login>::key is unchanged, so existing embeds and the server warmer keep working. Existing cached variants under old raw-string keys are not migrated; they will be re-warmed on next view. No drive-by cleanup, no marketing files touched. The separate security issue #3 is intentionally out of scope.