{"record":{"id":"daf0f7b05a3f3420","repo":"chenglou/pretext","slug":"missing-id-available-corpora-sources-map-sou","errorCode":null,"errorMessage":"Missing --id. Available corpora: ${sources.map(source => source.id).join(', ')}","messagePattern":"Missing --id\\. Available corpora: (.+?)","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"scripts/corpus-check.ts","lineNumber":298,"sourceCode":"const browser = parseBrowser(parseStringFlag('browser'))\nconst requestedPort = parseNumberFlag('port', Number.parseInt(process.env['CORPUS_CHECK_PORT'] ?? '0', 10))\nconst timeoutMs = parseNumberFlag('timeout', Number.parseInt(process.env['CORPUS_CHECK_TIMEOUT_MS'] ?? '180000', 10))\nconst requestedMethod = parseStringFlag('method')\nif (requestedMethod !== null && requestedMethod !== 'span' && requestedMethod !== 'range') {\n  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","sourceCodeStart":280,"sourceCodeEnd":316,"githubUrl":"https://github.com/chenglou/pretext/blob/ac49b09b7d83ede19581fa94a8b892b07d309baf/scripts/corpus-check.ts#L280-L316","documentation":"Thrown by corpus-check.ts when --id is absent. The corpus selector is mandatory because corpus-check measures one corpus at a time. The error enumerates every id in corpora/sources.json so the caller can copy a valid one. This fires at module top-level, before any browser session is created.","triggerScenarios":"parseStringFlag('id') returns null — no `--id=` argument was supplied on the command line. The script has no default id and no env-var fallback for --id, so silence is fatal.","commonSituations":"Running `bun run scripts/corpus-check.ts` bare expecting an interactive prompt; assuming --id has a default like the accuracy sweep; CI job template that forgot the id argument.","solutions":["Pick an id from the error message (it lists every corpus in corpora/sources.json) and pass `--id=<that-id>`.","Inspect corpora/sources.json directly to browse the full corpus metadata before choosing.","If scripting a batch, iterate over the ids in sources.json rather than hardcoding."],"exampleFix":"// before\nbun run scripts/corpus-check.ts --browser=chrome\n// after\nbun run scripts/corpus-check.ts --id=ja-kumo-no-ito --browser=chrome","handlingStrategy":"validation","validationCode":"// Require --id explicitly in any wrapper script before invoking corpus-check\nfunction requireCorpusId(argv: string[]): string {\n  const arg = argv.find(a => a.startsWith('--id='))\n  if (arg === undefined) {\n    const sources = await Bun.file('corpora/sources.json').json() as { id: string }[]\n    throw new Error(`--id is required. Available: ${sources.map(s => s.id).join(', ')}`)\n  }\n  return arg.slice('--id='.length)\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Always pass `--id=<corpus-id>`; corpus-check has no default and no env fallback for it.","Read corpora/sources.json to enumerate valid ids before choosing.","In batch scripts, iterate over sources.json rather than hardcoding an id that may be renamed."],"tags":["cli","validation","args","corpus-check"],"backgroundTag":null,"analyzedSha":"ac49b09b7d83ede19581fa94a8b892b07d309baf","analyzedAt":"2026-08-12T17:03:16.263Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}