{"record":{"id":"24fe0c7db07de0cc","repo":"chenglou/pretext","slug":"unknown-corpus-id-available-corpora-sources","errorCode":null,"errorMessage":"Unknown corpus ${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-check.ts","lineNumber":303,"sourceCode":"  throw new Error(`Unsupported --method ${requestedMethod}; expected span or range`)\n}\nconst overrideOptions: CorpusOverrideOptions = {\n  font: parseStringFlag('font'),\n  lineHeight: parseOptionalNumberFlag('lineHeight'),\n  method: requestedMethod as 'span' | 'range' | null,\n  sliceStart: parseOptionalNumberFlag('sliceStart'),\n  sliceEnd: parseOptionalNumberFlag('sliceEnd'),\n}\nconst sources = await loadSources()\nconst id = parseStringFlag('id')\n\nif (id === null) {\n  throw new Error(`Missing --id. Available corpora: ${sources.map(source => source.id).join(', ')}`)\n}\n\nconst meta = sources.find(source => source.id === id)\nif (meta === undefined) {\n  throw new Error(`Unknown corpus ${id}. Available corpora: ${sources.map(source => source.id).join(', ')}`)\n}\n\nconst lock = await acquireBrowserAutomationLock(browser)\nconst session = createBrowserSession(browser)\nconst diagnose = hasFlag('diagnose')\n\ntry {\n  const port = await getAvailablePort(requestedPort === 0 ? null : requestedPort)\n  const pageServer = await ensurePageServer(port, '/corpus', process.cwd())\n  serverProcess = pageServer.process\n  const baseUrl = `${pageServer.baseUrl}/corpus`\n  console.log(`${meta.id} (${meta.language}) — ${meta.title}`)\n\n  for (const width of getTargetWidths(meta)) {\n    const requestId = `${Date.now()}-${width}-${Math.random().toString(36).slice(2)}`\n    let url =\n      `${baseUrl}?id=${encodeURIComponent(meta.id)}` +\n      `&width=${width}` +","sourceCodeStart":285,"sourceCodeEnd":321,"githubUrl":"https://github.com/chenglou/pretext/blob/ac49b09b7d83ede19581fa94a8b892b07d309baf/scripts/corpus-check.ts#L285-L321","documentation":"Thrown by corpus-check.ts when --id was supplied but does not match any source.id in corpora/sources.json. Distinct from [30] (no id at all). The error re-lists all valid ids so a typo is immediately recoverable.","triggerScenarios":"parseStringFlag('id') returns a value; sources.find(s => s.id === id) returns undefined. Triggers on a typo (`--id=ja-kumo`), a stale id from an older revision of sources.json, a case mismatch (`--id=JA-Kumo-No-Ito` — matching is exact and case-sensitive), or an id copied from FONT_MATRIX that is not (yet) in sources.json.","commonSituations":"Typos and case mismatches; using an id from a different branch where sources.json was edited; confusing a corpus id with its language tag or title.","solutions":["Copy the id verbatim from the error's availability list (or from corpora/sources.json).","Respect casing and hyphenation — the lookup is a strict equality on source.id.","If you added a new corpus, ensure it has an entry in corpora/sources.json before referencing it."],"exampleFix":"// before\nbun run scripts/corpus-check.ts --id=ja-kumo\n// after\nbun run scripts/corpus-check.ts --id=ja-kumo-no-ito","handlingStrategy":"validation","validationCode":"const sources = await Bun.file('corpora/sources.json').json() as { id: string }[]\nconst VALID_IDS = new Set(sources.map(s => s.id))\nfunction assertKnownCorpusId(id: string): void {\n  if (!VALID_IDS.has(id)) {\n    throw new Error(`Unknown corpus ${id}. Valid: ${[...VALID_IDS].join(', ')}`)\n  }\n}","typeGuard":"function isKnownCorpusId(id: string, known: Set<string>): boolean {\n  return known.has(id)\n}","tryCatchPattern":null,"preventionTips":["Copy the id verbatim from corpora/sources.json — the lookup is exact and case-sensitive.","When adding a corpus, register it in sources.json before referencing it from CI.","Avoid transcribing ids from prose/docs; they may be stale relative to the checked-in sources.json."],"tags":["cli","validation","args","corpus-check"],"backgroundTag":null,"analyzedSha":"ac49b09b7d83ede19581fa94a8b892b07d309baf","analyzedAt":"2026-08-12T17:03:16.263Z","schemaVersion":2},"datasetVersion":"2026-08-12T18:17:37.767Z"}