{"record":{"id":"5324dff3b4a4edbd","repo":"chenglou/pretext","slug":"missing-pre-wrap-result-for-testcase-label","errorCode":null,"errorMessage":"Missing pre-wrap result for ${testCase.label}","messagePattern":"Missing pre-wrap result for (.+?)","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"scripts/pre-wrap-check.ts","lineNumber":138,"sourceCode":"        `&reportEndpoint=${encodeURIComponent(reportServer.endpoint)}`\n      const batchReport = await loadPostedReport(\n        session,\n        url,\n        () => reportServer.waitForReport(null),\n        requestId,\n        reportBrowser,\n        timeoutMs,\n      )\n      if (batchReport.status === 'error') {\n        throw new Error(batchReport.message ?? 'pre-wrap batch failed')\n      }\n\n      const batchResults = batchReport.results ?? []\n      const reportsByLabel = new Map(batchResults.map(result => [result.label, result.report]))\n      for (const testCase of PRE_WRAP_ORACLE_CASES) {\n        const report = reportsByLabel.get(testCase.label)\n        if (report === undefined) {\n          throw new Error(`Missing pre-wrap result for ${testCase.label}`)\n        }\n        printCaseResult(browser, testCase, report)\n        if (!reportIsExact(report)) ok = false\n      }\n    } finally {\n      reportServer.close()\n    }\n  } finally {\n    session?.close()\n    serverProcess?.kill()\n    lock.release()\n  }\n\n  return ok\n}\n\nconst port = await getAvailablePort(requestedPort === 0 ? null : requestedPort)\nlet overallOk = true","sourceCodeStart":120,"sourceCodeEnd":156,"githubUrl":"https://github.com/chenglou/pretext/blob/ac49b09b7d83ede19581fa94a8b892b07d309baf/scripts/pre-wrap-check.ts#L120-L156","documentation":"Thrown by the permanent pre-wrap oracle checker after a browser batch reports status:'ready' but a PRE_WRAP_ORACLE_CASES label is absent from the posted results. The script builds a Map<label, report> from the batch and requires every oracle case to be present. Unlike symbol-check.ts and keep-all-check.ts, this loop has no caseRunsInBrowser guard, so it expects every case for every browser unconditionally.","triggerScenarios":"Run pre-wrap-check when the /probe?batch=pre-wrap page posts {status:'ready', results:[...]} with fewer entries than PRE_WRAP_ORACLE_CASES.length. Concrete causes: a case label edited in src/test-data.ts while the served page bundle is stale (HMR/dist drift); the page's runProbeBatch skipped a case; or a future browser-restricted pre-wrap case is added (no guard exists to skip it script-side).","commonSituations":"Editing PRE_WRAP_ORACLE_CASES while bun start is serving an old bundle; running the checker against a stale --port page server; adding a browsers:[...] field to a pre-wrap case (page filters it, script still requires it).","solutions":["Restart bun start / the page server so pages/probe.ts bundle matches the current PRE_WRAP_ORACLE_CASES labels.","Confirm no PRE_WRAP_ORACLE_CASES entry gained a browsers: restriction; if one did, port the caseRunsInBrowser guard from symbol-check.ts:116,157 into pre-wrap-check.ts.","Re-run the checker (single-owner browser lock + side-channel POST can drop a report intermittently); if it reproduces, log batchResults to see which labels arrived.","Diff PRE_WRAP_ORACLE_CASES between the script import and the served page bundle (both import ../src/test-data.ts; verify the resolved file matches)."],"exampleFix":"// before (pre-wrap-check.ts:135)\nfor (const testCase of PRE_WRAP_ORACLE_CASES) {\n  const report = reportsByLabel.get(testCase.label)\n  if (report === undefined) throw new Error(`Missing pre-wrap result for ${testCase.label}`)\n\n// after\nfunction caseRunsInBrowser(c: ProbeOracleCase, b: AutomationBrowserKind): boolean {\n  return c.browsers === undefined || c.browsers.includes(b)\n}\nfor (const testCase of PRE_WRAP_ORACLE_CASES) {\n  if (!caseRunsInBrowser(testCase, browser)) continue\n  const report = reportsByLabel.get(testCase.label)\n  if (report === undefined) throw new Error(`Missing pre-wrap result for ${testCase.label}`)","handlingStrategy":"validation","validationCode":"// After building reportsByLabel, assert the page returned every case that should run in this browser.\nconst expected = PRE_WRAP_ORACLE_CASES.filter(c => c.browsers === undefined || c.browsers.includes(browser))\nconst missing = expected.filter(c => !reportsByLabel.has(c.label)).map(c => c.label)\nif (missing.length > 0) {\n  console.error('pre-wrap-check: page omitted labels (restart page server):', missing)\n  process.exit(2)\n}","typeGuard":"const caseRunsInBrowser = (c: ProbeOracleCase, b: AutomationBrowserKind): boolean =>\n  c.browsers === undefined || c.browsers.includes(b)\nconst hasLabel = (m: Map<string, ProbeReport>, t: ProbeOracleCase): boolean => m.has(t.label)","tryCatchPattern":null,"preventionTips":["Share one caseRunsInBrowser helper across all *-check.ts scripts so the script-side filter always matches the page-side caseRunsInCurrentBrowser filter.","Never add a browsers: field to a PRE_WRAP_ORACLE_CASES entry without mirroring the guard in pre-wrap-check.ts.","Restart bun start after editing any oracle cases in src/test-data.ts so the served pages/probe.ts bundle matches.","Treat a sudden 'Missing pre-wrap result' as a stale-bundle signal first; re-run before suspecting the engine."],"tags":["ci","browser-automation","oracle","test-infra","typescript"],"backgroundTag":null,"analyzedSha":"ac49b09b7d83ede19581fa94a8b892b07d309baf","analyzedAt":"2026-08-12T17:03:16.263Z","schemaVersion":2},"datasetVersion":"2026-08-12T18:17:37.767Z"}