{"record":{"id":"42c8c5f5322ea9b2","repo":"paperclipai/paperclip","slug":"malformed-request","errorCode":"malformed_request","errorMessage":"request must be a JSON object","messagePattern":"request must be a JSON object","errorType":"error_code","errorClass":"ProtocolError","httpStatus":null,"severity":"error","filePath":"packages/tailscale-https-broker/src/protocol.ts","lineNumber":56,"sourceCode":"export class ProtocolError extends Error {\n  constructor(\n    readonly code:\n      | \"unsupported_version\"\n      | \"malformed_request\"\n      | \"unknown_operation\"\n      | \"invalid_runtime_id\"\n      | \"invalid_port\",\n    message: string,\n    readonly requestId: string | null = null,\n  ) {\n    super(message);\n    this.name = \"ProtocolError\";\n  }\n}\n\nfunction asObject(value: unknown): Record<string, unknown> {\n  if (typeof value !== \"object\" || value === null || Array.isArray(value)) {\n    throw new ProtocolError(\"malformed_request\", \"request must be a JSON object\");\n  }\n  return value as Record<string, unknown>;\n}\n\nfunction requireStringField(\n  obj: Record<string, unknown>,\n  field: string,\n  re: RegExp,\n  code: ProtocolError[\"code\"],\n  requestId: string | null,\n): string {\n  const value = obj[field];\n  if (typeof value !== \"string\" || !re.test(value)) {\n    throw new ProtocolError(code, `invalid or missing field: ${field}`, requestId);\n  }\n  return value;\n}\n","sourceCodeStart":38,"sourceCodeEnd":74,"githubUrl":"https://github.com/paperclipai/paperclip/blob/120ae5428fa29bee300bcf806491cd4d965fbb7c/packages/tailscale-https-broker/src/protocol.ts#L38-L74","documentation":"asObject guard in the broker's request decoder: the JSON-decoded request body is not a plain object (it is an array, a scalar, or null). The ProtocolError('malformed_request') fails before any field is read, since nothing downstream can trust the shape.","triggerScenarios":"Thrown at packages/tailscale-https-broker/src/protocol.ts:56 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Send the request as a JSON object with the required protocol fields."],"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"}