chenglou/pretext · error · Error
Unknown corpus ${id}. Available corpora: ${sources.map(sourc
Error message
Unknown corpus ${id}. Available corpora: ${sources.map(source => source.id).join(', ')} What it means
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.
Source
Thrown at scripts/corpus-check.ts:303
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}`)
for (const width of getTargetWidths(meta)) {
const requestId = `${Date.now()}-${width}-${Math.random().toString(36).slice(2)}`
let url =
`${baseUrl}?id=${encodeURIComponent(meta.id)}` +
`&width=${width}` +View on GitHub (pinned to ac49b09b7d)
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.
Example fix
// before bun run scripts/corpus-check.ts --id=ja-kumo // after bun run scripts/corpus-check.ts --id=ja-kumo-no-ito
Defensive patterns
Strategy: validation
Validate before calling
const sources = await Bun.file('corpora/sources.json').json() as { id: string }[]
const VALID_IDS = new Set(sources.map(s => s.id))
function assertKnownCorpusId(id: string): void {
if (!VALID_IDS.has(id)) {
throw new Error(`Unknown corpus ${id}. Valid: ${[...VALID_IDS].join(', ')}`)
}
} Type guard
function isKnownCorpusId(id: string, known: Set<string>): boolean {
return known.has(id)
} Prevention
- 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.
When it happens
Trigger: 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.
Common situations: 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.
Related errors
- Invalid value for --${name}: ${raw}
- Unsupported --method ${requestedMethod}; expected span or ra
- Missing --id. Available corpora: ${sources.map(source => sou
- 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/24fe0c7db07de0cc.
Report an issue: GitHub.