{"record":{"id":"f4fa80fb15b6db82","repo":"paperclipai/paperclip","slug":"port-out-of-range-min-port-max-port","errorCode":null,"errorMessage":"port out of range [${MIN_PORT}, ${MAX_PORT}]","messagePattern":"port out of range \\[(.+?), (.+?)\\]","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/tailscale-https-broker/src/integers.ts","lineNumber":24,"sourceCode":"\n/** Ports are constrained to the valid TCP range. */\nexport const MIN_PORT = 1;\nexport const MAX_PORT = 65535;\n\n/**\n * Assert a JSON-decoded value is a canonical, safe, in-range port number.\n * Rejects non-numbers, non-integers, NaN/Infinity, negatives, and out-of-range\n * values. Returns the number so call sites read as validated.\n */\nexport function assertCanonicalPort(value: unknown): number {\n  if (typeof value !== \"number\") {\n    throw new Error(\"port must be a JSON number\");\n  }\n  if (!Number.isInteger(value)) {\n    throw new Error(\"port must be an integer\");\n  }\n  if (value < MIN_PORT || value > MAX_PORT) {\n    throw new Error(`port out of range [${MIN_PORT}, ${MAX_PORT}]`);\n  }\n  return value;\n}\n\n/**\n * Parse an integer from an untrusted STRING with strict canonical rules.\n * Rejects: empty, whitespace, signs, leading zeros (non-canonical), decimals,\n * exponents, thousands separators, Unicode digits, and anything that does not\n * round-trip exactly back to its canonical decimal form. Used at any boundary\n * where a numeric value could arrive as text.\n */\nexport function parseCanonicalIntegerString(raw: unknown): number {\n  if (typeof raw !== \"string\") {\n    throw new Error(\"expected a string integer\");\n  }\n  // Only ASCII digits, at least one, no sign, no whitespace. `^[0-9]+$` with a\n  // JS regex still matches only ASCII 0-9 (it does not match Unicode digits\n  // unless the `u` + property-escape form is used), which is what we want.","sourceCodeStart":6,"sourceCodeEnd":42,"githubUrl":"https://github.com/paperclipai/paperclip/blob/120ae5428fa29bee300bcf806491cd4d965fbb7c/packages/tailscale-https-broker/src/integers.ts#L6-L42","documentation":"assertCanonicalPort guard: the value is an integer but falls outside the valid TCP range [1, 65535] (negative, zero, NaN/Infinity, or too large). The port cannot name a real TCP listener, so it is rejected at the boundary.","triggerScenarios":"Thrown at packages/tailscale-https-broker/src/integers.ts:24 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Choose a port within the allowed range shown in the message [MIN_PORT, MAX_PORT]."],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"120ae5428fa29bee300bcf806491cd4d965fbb7c","analyzedAt":"2026-08-18T22:49:45.177Z","contentChangedAt":"2026-08-18T22:49:45.177Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}