{"record":{"id":"53ff486442cd6ef4","repo":"paperclipai/paperclip","slug":"tcp-must-be-an-object","errorCode":null,"errorMessage":"TCP must be an object","messagePattern":"TCP must be an object","errorType":"validation","errorClass":"ServeParseError","httpStatus":null,"severity":"error","filePath":"packages/tailscale-https-broker/src/serve-config.ts","lineNumber":67,"sourceCode":"  }\n  return assertCanonicalPort(Number(portText));\n}\n\n/**\n * Parse serve status JSON into a normalized, port-keyed model. Tolerates extra\n * top-level fields (Tailscale evolves its schema) but strictly validates the\n * `TCP` and `Web` shapes it depends on.\n */\nexport function parseServeStatus(json: unknown): ParsedServe {\n  if (!isObject(json)) {\n    throw new ServeParseError(\"serve status must be a JSON object\");\n  }\n  const entries = new Map<number, ServeEntry>();\n\n  const tcp = json.TCP;\n  const httpsPorts = new Set<number>();\n  if (tcp !== undefined && tcp !== null) {\n    if (!isObject(tcp)) throw new ServeParseError(\"TCP must be an object\");\n    for (const [portKey, value] of Object.entries(tcp)) {\n      if (!/^[0-9]+$/.test(portKey)) {\n        throw new ServeParseError(`non-numeric TCP port: ${portKey}`);\n      }\n      const port = assertCanonicalPort(Number(portKey));\n      if (!isObject(value)) throw new ServeParseError(`TCP[${portKey}] must be an object`);\n      if (value.HTTPS === true) httpsPorts.add(port);\n      if (!entries.has(port)) entries.set(port, { port, https: value.HTTPS === true, handlers: [] });\n      else entries.get(port)!.https = value.HTTPS === true;\n    }\n  }\n\n  const web = json.Web;\n  if (web !== undefined && web !== null) {\n    if (!isObject(web)) throw new ServeParseError(\"Web must be an object\");\n    for (const [hostKey, value] of Object.entries(web)) {\n      const port = portFromWebKey(hostKey);\n      if (!isObject(value)) throw new ServeParseError(`Web[${hostKey}] must be an object`);","sourceCodeStart":49,"sourceCodeEnd":85,"githubUrl":"https://github.com/paperclipai/paperclip/blob/120ae5428fa29bee300bcf806491cd4d965fbb7c/packages/tailscale-https-broker/src/serve-config.ts#L49-L85","documentation":"Shape guard in parseServeStatus: the serve status JSON has a `TCP` field but it is not an object (e.g. an array or scalar). The parser tolerates extra top-level fields but strictly validates TCP/Web shapes it depends on, so a malformed TCP block is rejected.","triggerScenarios":"Thrown at packages/tailscale-https-broker/src/serve-config.ts:67 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Fix the serve config so the TCP section is an object keyed by 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-14T05:17:10.506Z"}