{"record":{"id":"f55167213a4b16dd","repo":"vercel/next.js","slug":"value-is-not-a-non-negative-number","errorCode":null,"errorMessage":"'${value}' is not a non-negative number.","messagePattern":"'(.+?)' is not a non-negative number\\.","errorType":"exception","errorClass":"InvalidArgumentError","httpStatus":null,"severity":"error","filePath":"packages/next/src/server/lib/utils.ts","lineNumber":285,"sourceCode":" * @returns A string with the formatted node options.\n */\nexport function getFormattedNodeOptionsWithoutInspect() {\n  const args = getParsedNodeOptionsWithoutInspect()\n  if (Object.keys(args).length === 0) return ''\n\n  return formatNodeOptions(args).nodeOptions\n}\n\n/**\n * Check if the value is a valid positive integer and parse it. If it's not, it will throw an error.\n *\n * @param value The value to be parsed.\n */\nexport function parseValidPositiveInteger(value: string): number {\n  const parsedValue = parseInt(value, 10)\n\n  if (isNaN(parsedValue) || !isFinite(parsedValue) || parsedValue < 0) {\n    throw new InvalidArgumentError(`'${value}' is not a non-negative number.`)\n  }\n  return parsedValue\n}\n\nexport const RESTART_EXIT_CODE = 77\n\ntype HeapStatistics = {\n  used_heap_size: number\n  heap_size_limit: number\n}\n\n/**\n * @internal\n */\nexport function getMemoryRestartStats<T extends HeapStatistics>(\n  isDev: boolean,\n  devMemoryThresholdRestart: boolean,\n  getHeapStatistics: () => T","sourceCodeStart":267,"sourceCodeEnd":303,"githubUrl":"https://github.com/vercel/next.js/blob/0ae8c72462952df163f1b1e0726641bc5b40dc93/packages/next/src/server/lib/utils.ts#L267-L303","documentation":"Thrown (as InvalidArgumentError from commander) by parseValidPositiveInteger when a CLI argument value cannot be parsed into a non-negative integer (parseInt yields NaN, Infinity, or a negative number). Used to validate numeric CLI flags like port numbers.","triggerScenarios":"A Next.js CLI flag that expects a non-negative integer receives a non-numeric string, a negative number, or an empty string. parseValidPositiveInteger calls parseInt and rejects invalid results.","commonSituations":"Passing --port abc, --port -1, or a port from an env var that isn't a clean number. Script wrappers that forward unvalidated env values to the CLI.","solutions":["Pass a valid non-negative integer to the CLI flag (e.g. --port 3000).","If sourcing from an env var, validate/coerce it before forwarding: parseInt and check >= 0.","Avoid negative numbers and non-numeric strings for integer CLI flags."],"exampleFix":"// before: non-numeric passed\nnext start --port abc\n\n// after: valid integer\nnext start --port 3000","handlingStrategy":"validation","validationCode":"function parsePort(v: string): number {\n  const n = parseInt(v, 10)\n  if (isNaN(n) || !isFinite(n) || n < 0) throw new Error(`Invalid port: ${v}`)\n  return n\n}","typeGuard":"function isNonNegativeInt(v: string): boolean {\n  const n = parseInt(v, 10)\n  return !isNaN(n) && isFinite(n) && n >= 0 && String(n) === v\n}","tryCatchPattern":"null","preventionTips":["Validate env-sourced numbers before passing to the CLI.","Use parseInt and range-check in wrapper scripts.","Avoid negative or non-numeric values for integer flags."],"tags":["cli","validation","commander","arguments"],"analyzedSha":"0ae8c72462952df163f1b1e0726641bc5b40dc93","analyzedAt":"2026-08-06T19:44:29.143Z","schemaVersion":2},"datasetVersion":"2026-08-07T02:17:10.218Z"}