chenglou/pretext · error · Error
Invalid value for --${name}: ${raw}
Error message
Invalid value for --${name}: ${raw} What it means
parseNumberFlag() in letter-spacing-check.ts mirrors the same helper in keep-all-check.ts: it parses a `--<name>=<value>` numeric flag and throws when Number.parseInt yields a non-finite value. It guards the port/timeout flags for the letter-spacing oracle runner.
Source
Thrown at scripts/letter-spacing-check.ts:102
requestId?: string
results?: Array<{
label: string
report: ProbeReport
}>
message?: 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 parseBrowsers(value: string | null): AutomationBrowserKind[] {
const raw = (value ?? 'chrome,safari').trim()
if (raw.length === 0) return ['chrome', 'safari']
const browsers = raw
.split(',')
.map(part => part.trim().toLowerCase())
.filter(Boolean)
for (const browser of browsers) {
if (browser !== 'chrome' && browser !== 'safari' && browser !== 'firefox') {
throw new Error(`Unsupported browser ${browser}`)
}
}
View on GitHub (pinned to ac49b09b7d)
Solutions
- Supply an integer for the named flag, e.g. `--port=3210` / `--timeout=60000`.
- Omit the flag to accept the fallback default.
- Confirm the flag name in the message is one actually consumed by letter-spacing-check.ts.
Example fix
# before bun run letter-spacing-check -- --timeout=fast # after bun run letter-spacing-check -- --timeout=60000
Defensive patterns
Strategy: validation
Validate before calling
function readNumberFlag(name: string, fallback: number): number {
const prefix = `--${name}=`
const arg = process.argv.find(v => v.startsWith(prefix))
if (arg === undefined) return fallback
const raw = arg.slice(prefix.length)
const n = Number.parseInt(raw, 10)
if (!Number.isFinite(n)) {
console.error(`--${name} expects an integer, got: ${JSON.stringify(raw)}`)
process.exit(2)
}
return n
} Type guard
const isIntegerString = (v: string): boolean => /^-?\d+$/.test(v.trim())
Prevention
- Pass integers explicitly for port/timeout; avoid empty `--flag=`.
- Validate all numeric CLI args through one shared helper.
When it happens
Trigger: Running `bun run letter-spacing-check -- --port=abc`, `--timeout=` (empty), or any value where base-10 parseInt is NaN.
Common situations: Typo in a wrapper script, an unexpanded shell variable, or a stale flag value.
Related errors
- Invalid value for --${name}: ${raw}
- --step must be > 0
- Missing --id or --all. Available corpora: ${sources.map(sour
- Invalid value for --${name}: ${raw}
- Missing --id. Available corpora: ${sources.map(source => sou
AI-assisted analysis of chenglou/pretext@ac49b09b7d (2026-08-12).
Data as JSON: /api/errors/486b64b265b8487b.
Report an issue: GitHub.