Fix production build: RailProps.cardDocumentsByIdentifier needs | undefined - #90
Merged
Merged
Conversation
…low undefined deploy-frontend.yml #107 (and #106, before the flag even flipped) failed npm run build with a real tsc error: DisplayPage.tsx's RailProps declared cardDocumentsByIdentifier as { [id]: CardDocument }, but useCardDocumentsByIdentifier()'s own return type was correctly widened to { [id]: CardDocument | undefined } by an unrelated same-day PR (task #135, fixing a real crash) - a cross-PR interaction neither branch's own pre-merge CI could have caught alone. Every actual field access already used `?.`, so this is a type-only fix, no behavior change. Verified against the real failure mode, not just a local repro: confirmed the exact commit (93059f1) and job logs matched before concluding the diagnosis; regenerated the gitignored keyrune assets (frontend/src/common/generated/) that a naive worktree-node_modules-copy repro had silently skipped, which produced a first, unrelated false build failure. NEXT_PUBLIC_UNIFIED_DISPLAY_ENABLED=true npx next build now succeeds, and so does the flag-off build (unaffected). Full Jest suite (345 tests) and tests/DisplayPage.spec.ts (7 tests) still pass. Adds a standing verification-bar lesson to docs/lessons.md: any flag-gated page needs a real production build with its flag ON before shipping, since a dev-server Playwright suite never exercises the static-export prerender/type-check path a production build does.
This was referenced Jul 18, 2026
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.
Description
Fixes the
npm run buildfailure blockingdeploy-frontend.yml(failed at run #106, before the flag even flipped on, and again at #107 withNEXT_PUBLIC_UNIFIED_DISPLAY_ENABLED=true).Root cause:
DisplayPage.tsx'sRailProps.cardDocumentsByIdentifierwas typed as{ [identifier: string]: CardDocument }. An unrelated same-day PR (task #135, fixing a real crash inBleedOverrideSettings) correctly wideneduseCardDocumentsByIdentifier()'s own return type to{ [identifier: string]: CardDocument | undefined }— a project member'sCardDocumentgenuinely may not have been fetched yet, and the old unwidened type was hiding that possibility fromtscentirely (seecardDocumentsSlice.ts's own comment on the fix). Once both PRs were onmastertogether, passing the (now correctly-typed) hook result into the (still narrowly-typed)RailPropsbecame a real type error — a cross-PR interaction neither branch's own pre-merge CI could have caught in isolation, since each was individually type-correct against its own base.Fix: widen
RailProps.cardDocumentsByIdentifierto match. Every actual field access inDisplayPage.tsxalready used?.defensively (confirmed by reading every call site), so this is a type-annotation-only fix — zero runtime behavior change.Deviations from spec, with reasoning
None — this is a minimal, targeted fix scoped to exactly the reported failure.
How this was diagnosed (relevant since the first repro attempt gave a false negative)
deploy-frontend.ymlruns Proposal I: DOCS-AS-SITE-SOURCE spec (SPEC + HOLD, no build) #106 and Fix Discord sign-in: remove nested-anchor Nav.Link wrapper around AuthWidget #107 via the GitHub API rather than trusting a local repro's absence of an error — both showed the identicaltscerror atDisplayPage.tsx:555:13, and critically Proposal I: DOCS-AS-SITE-SOURCE spec (SPEC + HOLD, no build) #106 failed too, before the flag was ever turned on, which contradicted the initial "the flag flip is the delta" framing enough to warrant checking the actual logs instead of guessing further.node_modulescopied over from another checkout, to skip a slow reinstall) built clean — a false negative, because copyingnode_modulesskipsnpm install's postinstall step, which generatesfrontend/src/common/generated/keyruneCodepoints.json(gitignored, not committed). Regenerating that file (node scripts/generate-keyrune-assets.js) and confirming the worktree was actually on the failing commit (93059f1b, not a stale earlier one) reproduced the real error.Test plan
NEXT_PUBLIC_UNIFIED_DISPLAY_ENABLED=true npx next build— now succeeds (previously failed with the exact reported error).npx next build(flag off, default) — still succeeds, unaffected.tsc --noEmit— clean.tests/DisplayPage.spec.ts(7 Playwright tests againstnext dev) — all still passing, confirming the type-only fix didn't change runtime behavior.eslinton the changed file — clean (no new warnings).Merge-time checklist
deploy-frontend.ymlshould re-fire automatically and go green (per the owner's note — workflow + variable are already in place).Also adds a standing verification-bar lesson to
docs/lessons.md: any flag-gated page needs a real production build with its flag ON (FLAG=true npx next build) before its PR ships — a dev-server Playwright suite never exercises the static-export prerender/type-check path a production build does. Adding this to my own pre-push checks for the remaining Step 2 PRs.Generated by Claude Code