chenglou/pretext · error · Error

Unknown corpus ${options.id}. Available corpora: ${sources.m

Error message

Unknown corpus ${options.id}. Available corpora: ${sources.map(source => source.id).join(', ')}

What it means

`--id` was supplied but no entry in `corpora/sources.json` matches it. The error lists the valid ids so the operator can copy a correct one.

Source

Thrown at scripts/corpus-sweep.ts:252

  if (result.stderr.length > 0) process.stderr.write(result.stderr)
  if (result.status !== 0) {
    throw new Error(`corpus-check exited with status ${result.status ?? 'unknown'}`)
  }
}

const options = parseOptions()
options.port = await getAvailablePort(options.port === 0 ? null : options.port)
const sources = await loadSources()

const targets = options.all
  ? sources
  : (() => {
      if (options.id === null) {
        throw new Error(`Missing --id or --all. Available corpora: ${sources.map(source => source.id).join(', ')}`)
      }
      const meta = sources.find(source => source.id === options.id)
      if (meta === undefined) {
        throw new Error(`Unknown corpus ${options.id}. Available corpora: ${sources.map(source => source.id).join(', ')}`)
      }
      return [meta]
    })()

const lock = await acquireBrowserAutomationLock(options.browser)
const session = createBrowserSession(options.browser)
let serverProcess: ChildProcess | null = null
const summaries: SweepSummary[] = []

try {
  const pageServer = await ensurePageServer(options.port, '/corpus', process.cwd())
  serverProcess = pageServer.process
  const baseUrl = `${pageServer.baseUrl}/corpus`

  for (const meta of targets) {
    const widths = getSweepWidths(meta, options)
    const requestId = `${Date.now()}-${meta.id}-${Math.random().toString(36).slice(2)}`
    let url =

View on GitHub (pinned to ac49b09b7d)

Solutions

  1. Copy a valid id verbatim from the error's list.
  2. If you expected the id to exist, inspect `corpora/sources.json` for a rename or missing entry.

Example fix

// before
bun run scripts/corpus-sweep.ts --id=ja-kumo
// after
bun run scripts/corpus-sweep.ts --id=ja-kumo-no-ito
Defensive patterns

Strategy: validation

Validate before calling

const validIds = new Set(sources.map(s => s.id))
if (options.id !== null && !validIds.has(options.id)) {
  console.error(`Unknown corpus ${options.id}. Available: ${[...validIds].join(', ')}`)
  process.exit(2)
}

Type guard

const isKnownCorpus = (id: string, sources: CorpusMeta[]): id is string =>
  sources.some(s => s.id === id)

Prevention

When it happens

Trigger: `--id=ja-kumo` (misspelled/truncated) or referencing an id that was renamed or removed from sources.json.

Common situations: Typo; stale command after a corpus id rename; `corpora/sources.json` not regenerated after adding a corpus.

Related errors


AI-assisted analysis of chenglou/pretext@ac49b09b7d (2026-08-12). Data as JSON: /api/errors/6748bd3ee172e0e9. Report an issue: GitHub.