{"record":{"id":"2689be13833e0c40","repo":"chenglou/pretext","slug":"benchmark-run-reportindex-1-is-missing-corpus","errorCode":null,"errorMessage":"Benchmark run ${reportIndex + 1} is missing corpusResults[${rowIndex}]","messagePattern":"Benchmark run (.+?) is missing corpusResults\\[(.+?)\\]","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"scripts/benchmark-check.ts","lineNumber":160,"sourceCode":"\nfunction medianCorpusResults(reports: BenchmarkReport[]): CorpusBenchmarkResult[] | undefined {\n  const firstRows = reports[0]?.corpusResults\n  if (firstRows === undefined) {\n    for (let reportIndex = 1; reportIndex < reports.length; reportIndex++) {\n      assertSame(reports[reportIndex]!.corpusResults, undefined, 'corpusResults')\n    }\n    return undefined\n  }\n  for (let reportIndex = 1; reportIndex < reports.length; reportIndex++) {\n    assertSame(reports[reportIndex]!.corpusResults?.length, firstRows.length, 'corpusResults.length')\n  }\n\n  return firstRows.map((firstRow, rowIndex) => {\n    const result: CorpusBenchmarkResult = { ...firstRow }\n    for (let reportIndex = 0; reportIndex < reports.length; reportIndex++) {\n      const row = reports[reportIndex]!.corpusResults?.[rowIndex]\n      if (row === undefined) {\n        throw new Error(`Benchmark run ${reportIndex + 1} is missing corpusResults[${rowIndex}]`)\n      }\n      for (const metadataKey of CORPUS_METADATA_KEYS) {\n        assertSame(\n          row[metadataKey],\n          firstRow[metadataKey],\n          `corpusResults[${rowIndex}].${metadataKey}`,\n        )\n      }\n    }\n\n    for (const timingKey of CORPUS_TIMING_KEYS) {\n      result[timingKey] = median(reports.map(report => report.corpusResults![rowIndex]![timingKey]))\n    }\n\n    return result\n  })\n}\n","sourceCodeStart":142,"sourceCodeEnd":178,"githubUrl":"https://github.com/chenglou/pretext/blob/ac49b09b7d83ede19581fa94a8b892b07d309baf/scripts/benchmark-check.ts#L142-L178","documentation":"Thrown inside medianCorpusResults(): the corpus-results analogue of error 9. After asserting all runs share the same corpusResults length, accessing reports[reportIndex].corpusResults[rowIndex] returns undefined. This is a defensive guard that should be unreachable if the length check passed; it catches malformed corpus-results arrays (sparse or with undefined entries).","triggerScenarios":"A benchmark report's corpusResults array reports the correct length but one index is a hole/undefined — e.g. a sparse array serialization, a JSON null that was typed as a full row, or a page bug that pushed undefined into corpusResults while still incrementing a separate counter.","commonSituations":"Rare. Would arise from a corrupted report file, a page-side bug in assembling corpusResults, or an external tool that rewrote the JSON and dropped a row without updating the length. Not a typical user-facing error.","solutions":["Inspect reports[reportIndex].corpusResults for undefined/null entries and regenerate from a fresh run.","Verify the benchmark page's corpusResults builder never pushes undefined (e.g. guard each corpus measurement with a null check).","Run with --runs=1 to identify which run produces the malformed row.","Re-run from a clean checkout to rule out a locally edited report."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"// Validate corpusResults density before mediating.\nfunction hasDenseCorpusResults(report: BenchmarkReport): boolean {\n  const rows = report.corpusResults\n  return rows === undefined || rows.every(r => r !== undefined && r !== null)\n}","typeGuard":null,"tryCatchPattern":"// Skip the malformed row and continue mediating the rest.\nconst row = reports[reportIndex]!.corpusResults?.[rowIndex]\nif (row === undefined) {\n  console.warn(`Skipping missing corpusResults[${rowIndex}] in run ${reportIndex + 1}`)\n  continue\n}","preventionTips":["Ensure the page always pushes fully-populated corpus-result objects.","Regenerate report JSON from fresh runs; do not hand-edit.","Run --runs=1 to isolate which run produces the malformed entry."],"tags":["benchmark-check","defensive-guard","data-integrity","corpus","aggregation"],"backgroundTag":null,"analyzedSha":"ac49b09b7d83ede19581fa94a8b892b07d309baf","analyzedAt":"2026-08-12T17:03:16.263Z","schemaVersion":2},"datasetVersion":"2026-08-12T18:17:37.767Z"}