chenglou/pretext · error · Error

Benchmark run ${reportIndex + 1} is missing corpusResults[${

Error message

Benchmark run ${reportIndex + 1} is missing corpusResults[${rowIndex}]

What it means

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).

Source

Thrown at scripts/benchmark-check.ts:160

function medianCorpusResults(reports: BenchmarkReport[]): CorpusBenchmarkResult[] | undefined {
  const firstRows = reports[0]?.corpusResults
  if (firstRows === undefined) {
    for (let reportIndex = 1; reportIndex < reports.length; reportIndex++) {
      assertSame(reports[reportIndex]!.corpusResults, undefined, 'corpusResults')
    }
    return undefined
  }
  for (let reportIndex = 1; reportIndex < reports.length; reportIndex++) {
    assertSame(reports[reportIndex]!.corpusResults?.length, firstRows.length, 'corpusResults.length')
  }

  return firstRows.map((firstRow, rowIndex) => {
    const result: CorpusBenchmarkResult = { ...firstRow }
    for (let reportIndex = 0; reportIndex < reports.length; reportIndex++) {
      const row = reports[reportIndex]!.corpusResults?.[rowIndex]
      if (row === undefined) {
        throw new Error(`Benchmark run ${reportIndex + 1} is missing corpusResults[${rowIndex}]`)
      }
      for (const metadataKey of CORPUS_METADATA_KEYS) {
        assertSame(
          row[metadataKey],
          firstRow[metadataKey],
          `corpusResults[${rowIndex}].${metadataKey}`,
        )
      }
    }

    for (const timingKey of CORPUS_TIMING_KEYS) {
      result[timingKey] = median(reports.map(report => report.corpusResults![rowIndex]![timingKey]))
    }

    return result
  })
}

View on GitHub (pinned to ac49b09b7d)

Solutions

  1. Inspect reports[reportIndex].corpusResults for undefined/null entries and regenerate from a fresh run.
  2. Verify the benchmark page's corpusResults builder never pushes undefined (e.g. guard each corpus measurement with a null check).
  3. Run with --runs=1 to identify which run produces the malformed row.
  4. Re-run from a clean checkout to rule out a locally edited report.
Defensive patterns

Strategy: try-catch

Validate before calling

// Validate corpusResults density before mediating.
function hasDenseCorpusResults(report: BenchmarkReport): boolean {
  const rows = report.corpusResults
  return rows === undefined || rows.every(r => r !== undefined && r !== null)
}

Try / catch

// Skip the malformed row and continue mediating the rest.
const row = reports[reportIndex]!.corpusResults?.[rowIndex]
if (row === undefined) {
  console.warn(`Skipping missing corpusResults[${rowIndex}] in run ${reportIndex + 1}`)
  continue
}

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Related errors


AI-assisted analysis of chenglou/pretext@ac49b09b7d (2026-08-12). Data as JSON: /api/errors/2689be13833e0c40. Report an issue: GitHub.