From b7c26ff844ed1d0eea616be3536da1bb0dd404bc Mon Sep 17 00:00:00 2001 From: Michael Wang Date: Sun, 15 Nov 2026 07:22:20 +0000 Subject: [PATCH] fix(catalog): payload check treats the optional caption-overrides.json as absent, not failed (#7813) * fix(registry): catalog payload check passes a missing caption-overrides.json The runtime requests an optional caption-overrides.json on any page with a .caption-group and reads a 404 as "no overrides". The docs host has no such file, so every caption payload that uses .caption-group (caption-emoji-pop, caption-neon-accent, caption-pill-karaoke, caption-weight-shift) failed verify:catalog-payloads with a 404, its console line, and an aborted request. The check only ran on those payloads once a change regenerated them. The verifier now sets that miss aside, as `hyperframes validate` already does through shouldIgnoreHttpError. A non-404 status, any other failure on that URL, and an invalid overrides file still fail. To match the console line by URL, checkPageLoads now appends the resource URL to Chrome's "Failed to load resource" message, whose text leaves it out. * style(producer): name the failed resource URL instead of commenting it --- packages/producer/src/verifyStaticPage.ts | 8 +++++- scripts/verify-catalog-payloads.test.ts | 21 +++++++++++++++ scripts/verify-catalog-payloads.ts | 31 ++++++++++++++++++++++- 3 files changed, 58 insertions(+), 2 deletions(-) diff --git a/packages/producer/src/verifyStaticPage.ts b/packages/producer/src/verifyStaticPage.ts index 3fa65e473b..4c3c80735d 100644 --- a/packages/producer/src/verifyStaticPage.ts +++ b/packages/producer/src/verifyStaticPage.ts @@ -37,7 +37,13 @@ export async function checkPageLoads( failures.push(`pageerror: ${err instanceof Error ? err.message : String(err)}`); }); page.on("console", (msg) => { - if (msg.type() === "error") failures.push(`console.error: ${msg.text()}`); + if (msg.type() !== "error") return; + const failedResourceUrl = msg.text().startsWith("Failed to load resource") + ? msg.location().url + : ""; + failures.push( + `console.error: ${msg.text()}${failedResourceUrl ? ` (${failedResourceUrl})` : ""}`, + ); }); try { await page.goto(originUrl, { waitUntil: "domcontentloaded" }); diff --git a/scripts/verify-catalog-payloads.test.ts b/scripts/verify-catalog-payloads.test.ts index 73de6f90e8..4615a47185 100644 --- a/scripts/verify-catalog-payloads.test.ts +++ b/scripts/verify-catalog-payloads.test.ts @@ -9,6 +9,7 @@ import { declaresWebgpu, itemsFromDiff, withoutAbortedMedia, + withoutMissingCaptionOverrides, parsePayload, remainingFailures, withoutWebgpuAbsence, @@ -94,6 +95,26 @@ describe("withoutAbortedMedia", () => { }); }); +describe("withoutMissingCaptionOverrides", () => { + it("drops the runtime's missing caption-overrides.json and keeps every other failure", () => { + const url = "http://localhost:4000/caption-overrides.json"; + const miss = [ + `404 GET ${url}`, + `console.error: Failed to load resource: the server responded with a status of 404 (Not Found) (${url})`, + `request failed: ${url} (net::ERR_ABORTED)`, + ]; + const kept = [ + `500 GET ${url}`, + `request failed: ${url} (net::ERR_NAME_NOT_RESOLVED)`, + "404 GET http://localhost:4000/public/catalog/caption-overrides.json.png", + "404 GET http://localhost:4000/assets/caption-overrides.json", + "console.error: Failed to load resource: the server responded with a status of 404 (Not Found) (http://localhost:4000/x.png)", + "console.error: [HyperFrames] Invalid caption-overrides.json: expected an array", + ]; + assert.deepEqual(withoutMissingCaptionOverrides([...miss, ...kept]), kept); + }); +}); + it("browser selection includes regenerated edits and new untracked payloads", (t) => { const root = mkdtempSync(join(tmpdir(), "catalog-selection-")); t.after(() => rmSync(root, { recursive: true, force: true })); diff --git a/scripts/verify-catalog-payloads.ts b/scripts/verify-catalog-payloads.ts index b194799432..42ce1d5747 100644 --- a/scripts/verify-catalog-payloads.ts +++ b/scripts/verify-catalog-payloads.ts @@ -96,7 +96,36 @@ export function withoutWebgpuAbsence(webgpu: boolean, failures: string[]): strin /** What still counts as a failure for one item once the environment's own noise is set aside. */ export function remainingFailures(kindDir: string, item: string, failures: string[]): string[] { - return withoutAbortedMedia(withoutWebgpuAbsence(declaresWebgpu(kindDir, item), failures)); + return withoutMissingCaptionOverrides( + withoutAbortedMedia(withoutWebgpuAbsence(declaresWebgpu(kindDir, item), failures)), + ); +} + +const CAPTION_OVERRIDES_MISS = [ + /^404 GET (\S+)$/, + /^request failed: (\S+) \(net::ERR_ABORTED\)$/, + /^console\.error: Failed to load resource: the server responded with a status of 404 \(Not Found\) \((\S+)\)$/, +]; + +function isCaptionOverridesUrl(url: string): boolean { + try { + return new URL(url).pathname === "/caption-overrides.json"; + } catch { + return false; + } +} + +/** The runtime asks for an optional caption-overrides.json on any page with a .caption-group and + * reads a 404 as "no overrides"; the docs host has none. `hyperframes validate` passes the same + * miss (shouldIgnoreHttpError). Any other status, or an invalid file, still counts. */ +export function withoutMissingCaptionOverrides(failures: string[]): string[] { + return failures.filter( + (failure) => + !CAPTION_OVERRIDES_MISS.some((pattern) => { + const url = pattern.exec(failure)?.[1]; + return url !== undefined && isCaptionOverridesUrl(url); + }), + ); } export type Payload = { kind: "live"; html: string } | { kind: "marker"; reason: string };