chenglou/pretext · error · Error
Invalid value for --${name}: ${raw}
Error message
Invalid value for --${name}: ${raw} What it means
parseNumberFlag() in pre-wrap-check.ts is the same shared helper as in the other oracle scripts: it parses a `--<name>=<value>` integer flag and throws when Number.parseInt is non-finite. It guards the port/timeout flags for the pre-wrap oracle runner.
Source
Thrown at scripts/pre-wrap-check.ts:48
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, e.g. `--port=3210` / `--timeout=60000`.
- Omit the flag to use the fallback default.
- Confirm the flag name in the message is one consumed by pre-wrap-check.ts (port/timeout).
Example fix
# before bun run pre-wrap-check -- --port=any # after bun run pre-wrap-check -- --port=3210
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 for port/timeout; avoid empty `--flag=`.
- Centralize numeric CLI parsing in one helper per script family.
When it happens
Trigger: Running `bun run pre-wrap-check -- --port=abc`, `--timeout=` (empty), or any value whose base-10 parseInt is NaN.
Common situations: Typo in a wrapper script, unexpanded shell variable, or a stale placeholder 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/f73c791229673ded.
Report an issue: GitHub.