{"record":{"id":"f896c868d7b0319d","repo":"paperclipai/paperclip","slug":"port-must-be-an-integer","errorCode":null,"errorMessage":"port must be an integer","messagePattern":"port must be an integer","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/tailscale-https-broker/src/integers.ts","lineNumber":21,"sourceCode":" * generated only from integers that pass these checks, never from raw strings,\n * URLs, or unvalidated JSON (PAP-17050 verdict requirement #4).\n */\n\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  }","sourceCodeStart":3,"sourceCodeEnd":39,"githubUrl":"https://github.com/paperclipai/paperclip/blob/120ae5428fa29bee300bcf806491cd4d965fbb7c/packages/tailscale-https-broker/src/integers.ts#L3-L39","documentation":"assertCanonicalPort guard: the value is a JSON number but fractional (or otherwise not an integer). Non-integer ports must never reach shell commands or Serve configs, so the guard rejects before codegen.","triggerScenarios":"Thrown at packages/tailscale-https-broker/src/integers.ts:21 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Provide a whole-number port value with no fractional part."],"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-14T05:17:10.506Z"}