{"record":{"id":"1471f81529645981","repo":"vercel/next.js","slug":"invalid-numeric-value-for-key-value","errorCode":null,"errorMessage":"Invalid numeric value for --${key}: ${value}","messagePattern":"Invalid numeric value for --(.+?): (.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"bench/render-pipeline/benchmark.ts","lineNumber":107,"sourceCode":"  mode: StreamMode\n  routeResults: FullRoutePhaseResult[]\n  routeDocuments: RouteDocumentInfo[]\n}\n\nfunction parseBoolean(value: string): boolean {\n  return value === '1' || value === 'true' || value === 'yes'\n}\n\nfunction parseNumberArg(\n  args: Map<string, string>,\n  key: string,\n  fallback: number\n): number {\n  const value = args.get(key)\n  if (value === undefined) return fallback\n  const parsed = Number(value)\n  if (!Number.isFinite(parsed)) {\n    throw new Error(`Invalid numeric value for --${key}: ${value}`)\n  }\n  return parsed\n}\n\nfunction parseRoutes(rawRoutes: string | undefined): string[] {\n  if (!rawRoutes) {\n    return [\n      '/',\n      '/attributes',\n      '/tailwind',\n      '/dashboard',\n      '/docs',\n      '/blog',\n      '/streaming/light',\n      '/streaming/medium',\n      '/streaming/heavy',\n      '/streaming/chunkstorm',\n      '/streaming/wide',","sourceCodeStart":89,"sourceCodeEnd":125,"githubUrl":"https://github.com/vercel/next.js/blob/0ae8c72462952df163f1b1e0726641bc5b40dc93/bench/render-pipeline/benchmark.ts#L89-L125","documentation":"Thrown by parseNumberArg (benchmark.ts:107) when a CLI numeric option's value fails Number.isFinite after Number() coercion. Used for --warmup-requests, --serial-requests, --load-requests, --load-concurrency, --timeout-ms, and --port. The check rejects NaN (non-numeric), Infinity, and -Infinity, but does NOT reject negatives or zero — those flow through and may cause downstream issues.","triggerScenarios":"Passing any numeric flag a non-numeric or infinite value, e.g. --port=abc, --load-requests=1e999 (Infinity), --warmup-requests= (empty -> NaN), or a bare flag where the parser default-sets value to 'true' -> Number('true') = NaN.","commonSituations":"A bare flag without =N (--port instead of --port=3199) is parsed as 'true' and becomes NaN here; forwarding an unset env var as the value; typos like --port=3l99.","solutions":["Provide a finite integer: --port=3199, --load-requests=1200.","Never use bare numeric flags; always --key=value.","Note this guard does not catch negatives/zero — sanity-check ranges that matter (port, concurrency) in your wrapper.","If scripting the invocation, validate values are finite positive integers before passing them."],"exampleFix":"// before\n//   pnpm bench:render-pipeline --port=3l99 --load-requests=\n\n// after\n//   pnpm bench:render-pipeline --port=3199 --load-requests=1200","handlingStrategy":"validation","validationCode":"function parseFiniteInt(value: string | undefined, fallback: number, min = -Infinity): number {\n  if (value === undefined) return fallback\n  const n = Number(value)\n  if (!Number.isFinite(n)) throw new Error(`expected a number, got ${value}`)\n  if (!Number.isInteger(n) || n < min) throw new Error(`expected int >= ${min}, got ${value}`)\n  return n\n}","typeGuard":"function isFiniteNumericString(s: string): boolean {\n  const n = Number(s)\n  return s.trim() !== '' && Number.isFinite(n)\n}","tryCatchPattern":"try {\n  const port = parseNumberArg(args, 'port', 3199)\n} catch (err) {\n  console.error((err as Error).message, '\\nPass numeric flags as --key=integer')\n  process.exit(2)\n}","preventionTips":["Always use --key=value for numeric flags, never bare flags (bare -> 'true' -> NaN).","Add range validation in wrappers for values that have semantic bounds (port 1-65535, concurrency >= 1).","Note parseNumberArg rejects NaN/Infinity but NOT negatives or zero — validate those yourself.","Sanity-check templated env-var-derived values before forwarding."],"tags":["cli","argument-parsing","numeric","validation","render-pipeline"],"analyzedSha":"0ae8c72462952df163f1b1e0726641bc5b40dc93","analyzedAt":"2026-08-06T19:44:29.143Z","schemaVersion":2},"datasetVersion":"2026-08-07T02:17:10.218Z"}