chenglou/pretext · error · Error

No font matrix configured for ${options.id}. Available corpo

Error message

No font matrix configured for ${options.id}. Available corpora: ${Object.keys(FONT_MATRIX).join(', ')}

What it means

Thrown at the top level of corpus-font-matrix.ts immediately after [37]'s sources.json lookup succeeded. The id IS a real corpus, but it has no entry in the FONT_MATRIX constant (no font variants configured for sweeping). Distinct from [37] (not in sources at all) and from [35] (no id at all). The availability list is the FONT_MATRIX keys, which can be a strict subset of sources.json.

Source

Thrown at scripts/corpus-font-matrix.ts:443

  console.log(`${summary.corpusId} — ${summary.title}`)
  console.log(`widths: ${summary.widths.join(', ')}`)
  for (const variant of summary.variants) {
    console.log(`  ${variant.label}: ${variant.exactCount}/${variant.widthCount} exact | ${variant.mismatches.length} nonzero`)
    console.log(`    ${bucketMismatches(variant.mismatches)}`)
  }
}

const options = parseOptions()
options.port = await getAvailablePort(options.port === 0 ? null : options.port)
const sources = await loadSources()
const meta = sources.find(source => source.id === options.id)
if (meta === undefined) {
  throw new Error(`Unknown corpus ${options.id}. Available corpora: ${sources.map(source => source.id).join(', ')}`)
}

const variants = FONT_MATRIX[options.id]
if (variants === undefined) {
  throw new Error(`No font matrix configured for ${options.id}. Available corpora: ${Object.keys(FONT_MATRIX).join(', ')}`)
}

const widths = getSweepWidths(meta, options)
const lock = await acquireBrowserAutomationLock(options.browser)
const session = createBrowserSession(options.browser)
let serverProcess: ChildProcess | null = null

try {
  const pageServer = await ensurePageServer(options.port, '/corpus', process.cwd())
  serverProcess = pageServer.process
  const baseUrl = `${pageServer.baseUrl}/corpus`
  const variantResults: VariantResult[] = []

  for (const variant of variants) {
    const requestId = `${Date.now()}-${variant.id}-${Math.random().toString(36).slice(2)}`
    const reportServer = await startPostedReportServer<CorpusSweepReport>(requestId)
    const url =
      `${baseUrl}?id=${encodeURIComponent(meta.id)}` +

View on GitHub (pinned to ac49b09b7d)

Solutions

  1. Pick an id from the FONT_MATRIX keys listed in the error — those are the corpora actually configured for font sweeps.
  2. If you intended to sweep this corpus, add an entry to the FONT_MATRIX constant with at least one FontVariant ({ id, label, font, lineHeight }).
  3. Keep sources.json and FONT_MATRIX in sync when adding/renaming corpora.

Example fix

// before (corpus exists in sources.json but has no font variants)
bun run scripts/corpus-font-matrix.ts --id=some-corpus-without-variants
// after — either pick a configured corpus, or add an entry to FONT_MATRIX
// In corpus-font-matrix.ts:
//   const FONT_MATRIX = {
//     ...,
//     'some-corpus-without-variants': [
//       { id: 'default', label: 'Serif', font: '20px serif', lineHeight: 32 },
//     ],
//   }
Defensive patterns

Strategy: validation

Validate before calling

const MATRIX_KEYS = new Set(Object.keys(FONT_MATRIX))
function assertHasFontMatrix(id: string): void {
  if (!MATRIX_KEYS.has(id)) {
    throw new Error(`No font matrix configured for ${id}. Configured: ${[...MATRIX_KEYS].join(', ')}`)
  }
}

Type guard

function hasFontMatrix(id: string): boolean {
  return Object.prototype.hasOwnProperty.call(FONT_MATRIX, id)
}

Prevention

When it happens

Trigger: sources.find succeeded (meta is defined) but FONT_MATRIX[options.id] is undefined. Triggers when a corpus exists in sources.json but was never given font variants in the FONT_MATRIX table at the top of corpus-font-matrix.ts. This is a deliberate two-tier config: a corpus must be in both sources.json AND FONT_MATRIX to be sweepable.

Common situations: A new corpus was added to sources.json (so it passes [37]) but the contributor forgot to add a FONT_MATRIX entry; using a corpus id copied from corpus-check's availability list (which is sources.json-based) without checking it has font variants; renaming a corpus in sources.json but not in FONT_MATRIX.

Related errors


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