{"record":{"id":"3cf1e2b85c1143d9","repo":"paperclipai/paperclip","slug":"invalid-or-missing-field-field","errorCode":null,"errorMessage":"invalid or missing field: ${field}","messagePattern":"invalid or missing field: (.+?)","errorType":"error_code","errorClass":"ProtocolError","httpStatus":null,"severity":"error","filePath":"packages/tailscale-https-broker/src/protocol.ts","lineNumber":70,"sourceCode":"}\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\n/**\n * Decode a raw request frame (utf-8 JSON) into a validated BrokerRequest.\n * Throws ProtocolError on any violation; never mutates state.\n */\nexport function decodeRequest(frame: Buffer | string): BrokerRequest {\n  const buf = typeof frame === \"string\" ? Buffer.from(frame, \"utf8\") : frame;\n  if (buf.byteLength === 0) {\n    throw new ProtocolError(\"malformed_request\", \"empty request frame\");\n  }\n  if (buf.byteLength > MAX_REQUEST_BYTES) {\n    throw new ProtocolError(\"malformed_request\", \"request frame exceeds size limit\");\n  }\n\n  let parsed: unknown;","sourceCodeStart":52,"sourceCodeEnd":88,"githubUrl":"https://github.com/paperclipai/paperclip/blob/120ae5428fa29bee300bcf806491cd4d965fbb7c/packages/tailscale-https-broker/src/protocol.ts#L52-L88","documentation":"requireStringField guard in the protocol decoder: a mandatory string field (requestId, runtimeId, or handle) is missing, not a string, or fails its field-specific regex. The code (malformed_request, invalid_runtime_id, etc.) selects the protocol error; the message names the offending field.","triggerScenarios":"Thrown at packages/tailscale-https-broker/src/protocol.ts:70 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Include the named field with a valid value in the request object.","Check the protocol schema for the expected field names and types."],"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"}