chenglou/pretext · error · Error
Invalid value for --${name}: ${raw}
Error message
Invalid value for --${name}: ${raw} What it means
Thrown by the taxonomy script's `parseNumberFlag` when a required numeric flag is present but not a finite integer. Covers `--port`, `--timeout`, `--start`, `--end`, and `--step`.
Source
Thrown at scripts/corpus-taxonomy.ts:69
type TaxonomyEntry = {
width: number
diffPx: number
category: TaxonomyCategory
reason: string
deltaText: string
}
function parseStringFlag(name: string): string | null {
const prefix = `--${name}=`
const arg = process.argv.find(value => value.startsWith(prefix))
return arg === undefined ? null : arg.slice(prefix.length)
}
function parseNumberFlag(name: string, fallback: number): number {
const raw = parseStringFlag(name)
if (raw === null) return fallback
const parsed = Number.parseInt(raw, 10)
if (!Number.isFinite(parsed)) throw new Error(`Invalid value for --${name}: ${raw}`)
return parsed
}
function parseOptionalNumberFlag(name: string): number | null {
const raw = parseStringFlag(name)
if (raw === null) return null
const parsed = Number.parseInt(raw, 10)
if (!Number.isFinite(parsed)) throw new Error(`Invalid value for --${name}: ${raw}`)
return parsed
}
function parseBrowser(value: string | null): BrowserKind {
const browser = (value ?? process.env['CORPUS_CHECK_BROWSER'] ?? 'chrome').toLowerCase()
if (browser !== 'chrome' && browser !== 'safari') {
throw new Error(`Unsupported browser ${browser}; expected chrome or safari`)
}
return browser
}View on GitHub (pinned to ac49b09b7d)
Solutions
- Pass a base-10 integer, e.g. `--step=10`.
- Strip unit suffixes; `--timeout` is milliseconds (`--timeout=180000`).
- Check for a stray `=` with no value.
Example fix
// before bun run scripts/corpus-taxonomy.ts --id=ja-kumo-no-ito --step=10px // after bun run scripts/corpus-taxonomy.ts --id=ja-kumo-no-ito --step=10
Defensive patterns
Strategy: validation
Validate before calling
for (const name of ['port', 'timeout', 'start', 'end', 'step']) {
const raw = parseStringFlag(name)
if (raw !== null && !/^-?\d+$/.test(raw)) {
console.error(`--${name} must be a base-10 integer, got: ${raw}`)
process.exit(2)
}
} Type guard
const isIntString = (v: string): boolean => /^-?\d+$/.test(v)
Prevention
- Pass bare base-10 integers to numeric flags.
- Remember --timeout is milliseconds with no suffix.
- Avoid empty --flag= tokens.
When it happens
Trigger: `bun run scripts/corpus-taxonomy.ts --id=... --step=abc`, `--port=0x10`, or `--timeout=30s` — parseInt returns NaN.
Common situations: Typo; unit suffix on `--timeout` (milliseconds); hex value; empty `--flag=`.
Related errors
- Missing --id. Available corpora: ${sources.map(source => sou
- Invalid value for --${name}: ${raw}
- --step must be > 0
- Missing --id or --all. Available corpora: ${sources.map(sour
- Unsupported browser ${browser}; expected chrome or safari
AI-assisted analysis of chenglou/pretext@ac49b09b7d (2026-08-12).
Data as JSON: /api/errors/fb7d05c130c76d05.
Report an issue: GitHub.