chenglou/pretext · error · Error
Missing --id. Available corpora: ${sources.map(source => sou
Error message
Missing --id. Available corpora: ${sources.map(source => source.id).join(', ')} What it means
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.
Source
Thrown at scripts/corpus-check.ts:298
const browser = parseBrowser(parseStringFlag('browser'))
const requestedPort = parseNumberFlag('port', Number.parseInt(process.env['CORPUS_CHECK_PORT'] ?? '0', 10))
const timeoutMs = parseNumberFlag('timeout', Number.parseInt(process.env['CORPUS_CHECK_TIMEOUT_MS'] ?? '180000', 10))
const requestedMethod = parseStringFlag('method')
if (requestedMethod !== null && requestedMethod !== 'span' && requestedMethod !== 'range') {
throw new Error(`Unsupported --method ${requestedMethod}; expected span or range`)
}
const overrideOptions: CorpusOverrideOptions = {
font: parseStringFlag('font'),
lineHeight: parseOptionalNumberFlag('lineHeight'),
method: requestedMethod as 'span' | 'range' | null,
sliceStart: parseOptionalNumberFlag('sliceStart'),
sliceEnd: parseOptionalNumberFlag('sliceEnd'),
}
const sources = await loadSources()
const id = parseStringFlag('id')
if (id === null) {
throw new Error(`Missing --id. Available corpora: ${sources.map(source => source.id).join(', ')}`)
}
const meta = sources.find(source => source.id === id)
if (meta === undefined) {
throw new Error(`Unknown corpus ${id}. Available corpora: ${sources.map(source => source.id).join(', ')}`)
}
const lock = await acquireBrowserAutomationLock(browser)
const session = createBrowserSession(browser)
const diagnose = hasFlag('diagnose')
try {
const port = await getAvailablePort(requestedPort === 0 ? null : requestedPort)
const pageServer = await ensurePageServer(port, '/corpus', process.cwd())
serverProcess = pageServer.process
const baseUrl = `${pageServer.baseUrl}/corpus`
console.log(`${meta.id} (${meta.language}) — ${meta.title}`)
View on GitHub (pinned to ac49b09b7d)
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.
Example fix
// before bun run scripts/corpus-check.ts --browser=chrome // after bun run scripts/corpus-check.ts --id=ja-kumo-no-ito --browser=chrome
Defensive patterns
Strategy: validation
Validate before calling
// Require --id explicitly in any wrapper script before invoking corpus-check
function requireCorpusId(argv: string[]): string {
const arg = argv.find(a => a.startsWith('--id='))
if (arg === undefined) {
const sources = await Bun.file('corpora/sources.json').json() as { id: string }[]
throw new Error(`--id is required. Available: ${sources.map(s => s.id).join(', ')}`)
}
return arg.slice('--id='.length)
} Prevention
- 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.
When it happens
Trigger: 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.
Common situations: 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.
Related errors
- Invalid value for --${name}: ${raw}
- Unsupported --method ${requestedMethod}; expected span or ra
- Unknown corpus ${id}. Available corpora: ${sources.map(sourc
- Unsupported browser ${browser}; expected chrome or safari
- Invalid value for --${name}: ${raw}
AI-assisted analysis of chenglou/pretext@ac49b09b7d (2026-08-12).
Data as JSON: /api/errors/daf0f7b05a3f3420.
Report an issue: GitHub.