{"record":{"id":"87fa1e33f9ebab87","repo":"chenglou/pretext","slug":"unknown-corpus-options-id-available-corpora","errorCode":null,"errorMessage":"Unknown corpus ${options.id}. Available corpora: ${sources.map(source => source.id).join(', ')}","messagePattern":"Unknown corpus (.+?)\\. Available corpora: (.+?)","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"scripts/corpus-font-matrix.ts","lineNumber":438,"sourceCode":"    .map(([diffPx, widths]) => `${diffPx > 0 ? '+' : ''}${diffPx}px: ${widths.join(', ')}`)\n    .join(' | ')\n}\n\nfunction printSummary(summary: MatrixSummary): void {\n  console.log(`${summary.corpusId} — ${summary.title}`)\n  console.log(`widths: ${summary.widths.join(', ')}`)\n  for (const variant of summary.variants) {\n    console.log(`  ${variant.label}: ${variant.exactCount}/${variant.widthCount} exact | ${variant.mismatches.length} nonzero`)\n    console.log(`    ${bucketMismatches(variant.mismatches)}`)\n  }\n}\n\nconst options = parseOptions()\noptions.port = await getAvailablePort(options.port === 0 ? null : options.port)\nconst sources = await loadSources()\nconst meta = sources.find(source => source.id === options.id)\nif (meta === undefined) {\n  throw new Error(`Unknown corpus ${options.id}. Available corpora: ${sources.map(source => source.id).join(', ')}`)\n}\n\nconst variants = FONT_MATRIX[options.id]\nif (variants === undefined) {\n  throw new Error(`No font matrix configured for ${options.id}. Available corpora: ${Object.keys(FONT_MATRIX).join(', ')}`)\n}\n\nconst widths = getSweepWidths(meta, options)\nconst lock = await acquireBrowserAutomationLock(options.browser)\nconst session = createBrowserSession(options.browser)\nlet serverProcess: ChildProcess | null = null\n\ntry {\n  const pageServer = await ensurePageServer(options.port, '/corpus', process.cwd())\n  serverProcess = pageServer.process\n  const baseUrl = `${pageServer.baseUrl}/corpus`\n  const variantResults: VariantResult[] = []\n","sourceCodeStart":420,"sourceCodeEnd":456,"githubUrl":"https://github.com/chenglou/pretext/blob/ac49b09b7d83ede19581fa94a8b892b07d309baf/scripts/corpus-font-matrix.ts#L420-L456","documentation":"Thrown at the top level of corpus-font-matrix.ts after parseOptions has returned. The parsed --id is looked up against corpora/sources.json (loadSources + sources.find). If no source matches, throws listing all source ids. This is the font-matrix analogue of [31] and uses the SAME sources.json availability list.","triggerScenarios":"options.id passed parseOptions (so it is non-null) but sources.find(s => s.id === options.id) returns undefined. Triggers on a typo, a case mismatch, or an id that exists in FONT_MATRIX but was never added to sources.json (a configuration inconsistency).","commonSituations":"An id was added to FONT_MATRIX without a matching sources.json entry; a renamed corpus where one file was updated but not the other; case-sensitive typo.","solutions":["Use an id that exists in corpora/sources.json (the error lists them).","If adding a new font-matrix corpus, add the sources.json entry FIRST — both this lookup and the [38] check depend on it.","Copy the id verbatim; the find is case-sensitive equality."],"exampleFix":"// before\nbun run scripts/corpus-font-matrix.ts --id=ja-kumo\n// after\nbun run scripts/corpus-font-matrix.ts --id=ja-kumo-no-ito","handlingStrategy":"validation","validationCode":"const sources = await Bun.file('corpora/sources.json').json() as { id: string }[]\nconst SOURCE_IDS = new Set(sources.map(s => s.id))\nfunction assertInSources(id: string): void {\n  if (!SOURCE_IDS.has(id)) {\n    throw new Error(`Unknown corpus ${id}. Valid sources: ${[...SOURCE_IDS].join(', ')}`)\n  }\n}","typeGuard":"function isInSources(id: string, known: Set<string>): boolean {\n  return known.has(id)\n}","tryCatchPattern":null,"preventionTips":["Add new corpora to sources.json FIRST — both this lookup and [38]'s FONT_MATRIX check depend on it.","Copy ids verbatim; the find is case-sensitive equality.","When renaming a corpus, update sources.json, FONT_MATRIX, and any CI invocation in the same change."],"tags":["cli","validation","args","corpus-font-matrix","config"],"backgroundTag":null,"analyzedSha":"ac49b09b7d83ede19581fa94a8b892b07d309baf","analyzedAt":"2026-08-12T17:03:16.263Z","schemaVersion":2},"datasetVersion":"2026-08-12T18:17:37.767Z"}