{"record":{"id":"a2a4a0decde94c33","repo":"chenglou/pretext","slug":"invalid-value-for-name-raw-a2a4a0","errorCode":null,"errorMessage":"Invalid value for --${name}: ${raw}","messagePattern":"Invalid value for --(.+?): (.+?)","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"scripts/corpus-sweep.ts","lineNumber":92,"sourceCode":"  timeoutMs: number\n  font: string | null\n  lineHeight: number | null\n  diagnose: boolean\n  diagnoseLimit: number\n}\n\nfunction parseStringFlag(name: string): string | null {\n  const prefix = `--${name}=`\n  const arg = process.argv.find(value => value.startsWith(prefix))\n  return arg === undefined ? null : arg.slice(prefix.length)\n}\n\nfunction parseNumberFlag(name: string, fallback: number): number {\n  const raw = parseStringFlag(name)\n  if (raw === null) return fallback\n  const parsed = Number.parseInt(raw, 10)\n  if (!Number.isFinite(parsed)) {\n    throw new Error(`Invalid value for --${name}: ${raw}`)\n  }\n  return parsed\n}\n\nfunction parseOptionalNumberFlag(name: string): number | null {\n  const raw = parseStringFlag(name)\n  if (raw === null) return null\n  const parsed = Number.parseInt(raw, 10)\n  if (!Number.isFinite(parsed)) {\n    throw new Error(`Invalid value for --${name}: ${raw}`)\n  }\n  return parsed\n}\n\nfunction hasFlag(name: string): boolean {\n  return process.argv.includes(`--${name}`)\n}\n","sourceCodeStart":74,"sourceCodeEnd":110,"githubUrl":"https://github.com/chenglou/pretext/blob/ac49b09b7d83ede19581fa94a8b892b07d309baf/scripts/corpus-sweep.ts#L74-L110","documentation":"Thrown by the sweep's `parseNumberFlag` when a required numeric CLI flag is present but `Number.parseInt(raw, 10)` is not finite (non-numeric or empty). It covers `--start`, `--end`, `--step`, `--port`, `--timeout`, and `--diagnose-limit`.","triggerScenarios":"Invoke `bun run scripts/corpus-sweep.ts --step=abc`, `--step=`, `--port=0x10`, or `--timeout=30s`. Any of these makes parseInt return NaN.","commonSituations":"Typo in a flag value; copy-pasting a unit suffix like `180s` (timeout is milliseconds); passing a hex value; a stray empty `--flag=`.","solutions":["Pass a base-10 integer for the flagged option, e.g. `--step=10`.","Strip any unit suffix; `--timeout` is milliseconds, so use `--timeout=180000` not `180s`.","Check for a stray `=` with no value after it."],"exampleFix":"// before\nbun run scripts/corpus-sweep.ts --id=ja-kumo-no-ito --step=10px\n// after\nbun run scripts/corpus-sweep.ts --id=ja-kumo-no-ito --step=10","handlingStrategy":"validation","validationCode":"function assertIntFlag(name: string): void {\n  const raw = parseStringFlag(name)\n  if (raw !== null && !/^-?\\d+$/.test(raw)) {\n    console.error(`--${name} must be a base-10 integer, got: ${raw}`)\n    process.exit(2)\n  }\n}","typeGuard":"const isIntString = (v: string): boolean => /^-?\\d+$/.test(v)","tryCatchPattern":null,"preventionTips":["Pass bare base-10 integers to every numeric flag.","Never append unit suffixes; consult DEVELOPMENT.md for units (timeout is ms).","Avoid empty --flag= tokens."],"tags":["cli","argument-parsing","validation"],"backgroundTag":null,"analyzedSha":"ac49b09b7d83ede19581fa94a8b892b07d309baf","analyzedAt":"2026-08-12T17:03:16.263Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}