{"record":{"id":"f32cfd37b35b9e35","repo":"chenglou/pretext","slug":"missing-id-or-all-available-corpora-source","errorCode":null,"errorMessage":"Missing --id or --all. Available corpora: ${sources.map(source => source.id).join(', ')}","messagePattern":"Missing --id or --all\\. Available corpora: (.+?)","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"scripts/corpus-sweep.ts","lineNumber":248,"sourceCode":"    encoding: 'utf8',\n  })\n\n  if (result.stdout.length > 0) process.stdout.write(result.stdout)\n  if (result.stderr.length > 0) process.stderr.write(result.stderr)\n  if (result.status !== 0) {\n    throw new Error(`corpus-check exited with status ${result.status ?? 'unknown'}`)\n  }\n}\n\nconst options = parseOptions()\noptions.port = await getAvailablePort(options.port === 0 ? null : options.port)\nconst sources = await loadSources()\n\nconst targets = options.all\n  ? sources\n  : (() => {\n      if (options.id === null) {\n        throw new Error(`Missing --id or --all. Available corpora: ${sources.map(source => source.id).join(', ')}`)\n      }\n      const meta = sources.find(source => source.id === options.id)\n      if (meta === undefined) {\n        throw new Error(`Unknown corpus ${options.id}. Available corpora: ${sources.map(source => source.id).join(', ')}`)\n      }\n      return [meta]\n    })()\n\nconst lock = await acquireBrowserAutomationLock(options.browser)\nconst session = createBrowserSession(options.browser)\nlet serverProcess: ChildProcess | null = null\nconst summaries: SweepSummary[] = []\n\ntry {\n  const pageServer = await ensurePageServer(options.port, '/corpus', process.cwd())\n  serverProcess = pageServer.process\n  const baseUrl = `${pageServer.baseUrl}/corpus`\n","sourceCodeStart":230,"sourceCodeEnd":266,"githubUrl":"https://github.com/chenglou/pretext/blob/ac49b09b7d83ede19581fa94a8b892b07d309baf/scripts/corpus-sweep.ts#L230-L266","documentation":"The sweep needs a target: either one corpus via `--id=` or all corpora via `--all`. Without either it throws, listing the available ids read from `corpora/sources.json`.","triggerScenarios":"`bun run scripts/corpus-sweep.ts` with no targeting flags.","commonSituations":"First-time use; forgetting the flag after adding a new corpus; a wrapper script that drops the id argument.","solutions":["Add `--id=<corpusId>` using one of the ids printed in the message, or pass `--all`."],"exampleFix":"// before\nbun run scripts/corpus-sweep.ts\n// after\nbun run scripts/corpus-sweep.ts --id=ja-kumo-no-ito\n// or sweep every corpus\nbun run scripts/corpus-sweep.ts --all","handlingStrategy":"validation","validationCode":"if (options.id === null && !options.all) {\n  console.error(`Missing --id or --all. Available corpora: ${sources.map(s => s.id).join(', ')}`)\n  process.exit(2)\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Always pass either --id or --all in CI wrappers.","Print sources with a --list mode if you script corpus selection dynamically."],"tags":["cli","argument-parsing","validation"],"backgroundTag":null,"analyzedSha":"ac49b09b7d83ede19581fa94a8b892b07d309baf","analyzedAt":"2026-08-12T17:03:16.263Z","schemaVersion":2},"datasetVersion":"2026-08-12T18:17:37.767Z"}