chenglou/pretext · error · Error

Corpus sweep report was missing rows for ${corpusId}

Error message

Corpus sweep report was missing rows for ${corpusId}

What it means

Guard in `getSweepRows`: the browser page posted a report whose status is not 'error' but whose `rows` field is undefined. It prevents the downstream filter/map from treating undefined rows as an empty (all-exact) result.

Source

Thrown at scripts/corpus-sweep.ts:200

    }
  }

  return [...buckets.entries()]
    .sort((a, b) => a[0] - b[0])
    .map(([diffPx, widths]) => `${diffPx > 0 ? '+' : ''}${diffPx}px: ${widths.join(', ')}`)
    .join(' | ')
}

function printSummary(summary: SweepSummary): void {
  console.log(
    `${summary.corpusId} (${summary.language}) | ${summary.exactCount}/${summary.widthCount} exact | ${summary.mismatches.length} nonzero`,
  )
  console.log(`  ${bucketMismatches(summary.mismatches)}`)
}

function getSweepRows(report: CorpusSweepReport, corpusId: string): CorpusSweepRow[] {
  if (report.rows === undefined) {
    throw new Error(`Corpus sweep report was missing rows for ${corpusId}`)
  }
  return report.rows
}

function runDetailedDiagnose(meta: CorpusMeta, mismatches: SweepMismatch[], options: SweepOptions): void {
  if (!options.diagnose || mismatches.length === 0) return

  const widths = mismatches
    .slice(0, options.diagnoseLimit)
    .map(mismatch => String(mismatch.width))

  console.log(`diagnosing ${meta.id} at ${widths.length} widths: ${widths.join(', ')}`)

  const args = ['run', 'scripts/corpus-check.ts', `--id=${meta.id}`, '--diagnose', ...widths]
  if (options.font !== null) {
    args.push(`--font=${options.font}`)
  }
  if (options.lineHeight !== null) {

View on GitHub (pinned to ac49b09b7d)

Solutions

  1. Confirm the corpus width range overlaps `--start`/`--end` so the widths list is non-empty.
  2. Re-run; if persistent, open the `/corpus?id=...&widths=...&report=1` URL headed and inspect console errors.
  3. Raise `--timeout`; a slow measurement can post a ready report before rows are attached.

Example fix

// before: corpus bounds exclude the whole sweep range
// sources.json: { "id": "x", "min_width": 950 }
bun run scripts/corpus-sweep.ts --id=x --start=300 --end=900
// after
bun run scripts/corpus-sweep.ts --id=x --start=900 --end=1200
Defensive patterns

Strategy: retry

Validate before calling

const widths = getSweepWidths(meta, options)
if (widths.length === 0) {
  console.error(`No widths in range for ${meta.id}; skipping`)
  continue
}

Prevention

When it happens

Trigger: The `/corpus` page posts `{status:'ready'}` without `rows` — e.g., the widths list was empty after `min_width`/`max_width` clamping, or the POST payload was truncated on the side channel.

Common situations: Corpus width bounds in `corpora/sources.json` clamp the range to nothing; transport truncation; a stale page build that doesn't attach rows.

Related errors


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