chenglou/pretext · error · Error
Invalid value for --${name}: ${raw}
Error message
Invalid value for --${name}: ${raw} What it means
Identical helper shape to error 81, here in scripts/symbol-check.ts. parseNumberFlag guards --port (line 77) and --timeout (line 79, default 60000). Throws when Number.parseInt(raw, 10) is NaN. Called at module top-level, so it aborts before any browser automation starts. Note parseInt tolerates surrounding whitespace, so '8080 ' is fine, but '8080px' throws.
Source
Thrown at scripts/symbol-check.ts:55
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
- Use plain integers: --port=0, --timeout=60000 (milliseconds).
- Remember --timeout is milliseconds, not seconds.
- The message names the bad flag and shows the raw value.
Example fix
# before bun run scripts/symbol-check.ts --timeout=30s # after bun run scripts/symbol-check.ts --timeout=30000
Defensive patterns
Strategy: validation
Validate before calling
const isIntFlag = (raw: string | null): boolean =>
raw === null || /^-?\d+$/.test(raw.trim())
for (const name of ['port', 'timeout'] as const) {
const raw = parseStringFlag(name)
if (!isIntFlag(raw)) {
console.error(`--${name} expects an integer (ms for timeout), got ${JSON.stringify(raw)}`)
process.exit(2)
}
} Type guard
const isIntFlag = (s: string | null): s is string => s !== null && Number.isFinite(Number.parseInt(s, 10))
Prevention
- --timeout is milliseconds; --port is unitless. Never append units like 's' or 'px'.
- Validate before launch since these flags are read at module top-level and abort early.
When it happens
Trigger: --port=abc; --timeout=10s; --port= (empty). --timeout is milliseconds, so '30s' is a common mistake.
Common situations: Copy-pasting units into --timeout (30s instead of 30000); empty --port=; forgetting --timeout is in ms.
Related errors
- Invalid value for --${name}: ${raw}
- Invalid value for --${name}: ${raw}
- --step must be > 0
- Missing --id or --all. Available corpora: ${sources.map(sour
- Invalid value for --${name}: ${raw}
AI-assisted analysis of chenglou/pretext@ac49b09b7d (2026-08-12).
Data as JSON: /api/errors/98bdf2cb203648de.
Report an issue: GitHub.