{"record":{"id":"67e3d9a1a62bef80","repo":"paperclipai/paperclip","slug":"serve-status-must-be-a-json-object","errorCode":null,"errorMessage":"serve status must be a JSON object","messagePattern":"serve status must be a JSON object","errorType":"validation","errorClass":"ServeParseError","httpStatus":null,"severity":"error","filePath":"packages/tailscale-https-broker/src/serve-config.ts","lineNumber":60,"sourceCode":"  const idx = key.lastIndexOf(\":\");\n  if (idx <= 0 || idx === key.length - 1) {\n    throw new ServeParseError(`malformed Web key: ${JSON.stringify(key)}`);\n  }\n  const portText = key.slice(idx + 1);\n  if (!/^[0-9]+$/.test(portText)) {\n    throw new ServeParseError(`non-numeric port in Web key: ${JSON.stringify(key)}`);\n  }\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  }","sourceCodeStart":42,"sourceCodeEnd":78,"githubUrl":"https://github.com/paperclipai/paperclip/blob/120ae5428fa29bee300bcf806491cd4d965fbb7c/packages/tailscale-https-broker/src/serve-config.ts#L42-L78","documentation":"Top-level shape guard in parseServeStatus, which parses `tailscale serve status` JSON: the decoded value is not a JSON object (array, string, null, etc.). Nothing downstream can be read, so parsing fails before TCP/Web normalization.","triggerScenarios":"Thrown at packages/tailscale-https-broker/src/serve-config.ts:60 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Ensure `tailscale serve status --json` returns a JSON object; check the tailscale version and command output."],"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"}