{"record":{"id":"2f39f335337bc2d1","repo":"chenglou/pretext","slug":"step-must-be-0-2f39f3","errorCode":null,"errorMessage":"--step must be > 0","messagePattern":"--step must be > 0","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"scripts/corpus-sweep.ts","lineNumber":127,"sourceCode":"}\n\nfunction parseBrowser(value: string | null): BrowserKind {\n  const browser = (value ?? process.env['CORPUS_CHECK_BROWSER'] ?? 'chrome').toLowerCase()\n  if (browser !== 'chrome' && browser !== 'safari') {\n    throw new Error(`Unsupported browser ${browser}; expected chrome or safari`)\n  }\n  return browser\n}\n\nasync function loadSources(): Promise<CorpusMeta[]> {\n  return await Bun.file('corpora/sources.json').json()\n}\n\nfunction parseOptions(): SweepOptions {\n  const start = parseNumberFlag('start', 300)\n  const end = parseNumberFlag('end', 900)\n  const step = parseNumberFlag('step', 10)\n  if (step <= 0) throw new Error('--step must be > 0')\n  if (end < start) throw new Error('--end must be >= --start')\n  if (parseStringFlag('samples') !== null) {\n    throw new Error('--samples is obsolete for corpus-sweep; use the default step-based sweep or sampled font-matrix/taxonomy runs instead')\n  }\n\n  return {\n    id: parseStringFlag('id'),\n    all: hasFlag('all'),\n    start,\n    end,\n    step,\n    port: parseNumberFlag('port', Number.parseInt(process.env['CORPUS_CHECK_PORT'] ?? '0', 10)),\n    browser: parseBrowser(parseStringFlag('browser')),\n    output: parseStringFlag('output'),\n    timeoutMs: parseNumberFlag('timeout', Number.parseInt(process.env['CORPUS_CHECK_TIMEOUT_MS'] ?? '180000', 10)),\n    font: parseStringFlag('font'),\n    lineHeight: parseOptionalNumberFlag('lineHeight'),\n    diagnose: hasFlag('diagnose'),","sourceCodeStart":109,"sourceCodeEnd":145,"githubUrl":"https://github.com/chenglou/pretext/blob/ac49b09b7d83ede19581fa94a8b892b07d309baf/scripts/corpus-sweep.ts#L109-L145","documentation":"Thrown after `--step` parses as a valid integer but is zero or negative. The sweep loop increments width by `step`, so a non-positive step would loop forever or make no progress.","triggerScenarios":"`--step=0` or `--step=-10`.","commonSituations":"Trying to disable stepping; a sign error; copy-pasting a value intended for a different flag.","solutions":["Pass a positive step, e.g. `--step=10` (the default).","If you want a single width, use the taxonomy/check script with a positional width instead of zeroing the step."],"exampleFix":"// before\nbun run scripts/corpus-sweep.ts --id=ja-kumo-no-ito --step=0\n// after\nbun run scripts/corpus-sweep.ts --id=ja-kumo-no-ito --step=10","handlingStrategy":"validation","validationCode":"const step = parseNumberFlag('step', 10)\nif (step <= 0) {\n  console.error('--step must be > 0')\n  process.exit(2)\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Keep --step at its default (10) unless you have a reason to change it.","For single-width checks, pass the width positionally to the taxonomy/check script instead of zeroing the step."],"tags":["cli","argument-parsing","validation","sweep"],"backgroundTag":null,"analyzedSha":"ac49b09b7d83ede19581fa94a8b892b07d309baf","analyzedAt":"2026-08-12T17:03:16.263Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}