{"record":{"id":"81d5ecde281be254","repo":"diegosouzapw/OmniRoute","slug":"context-must-be-an-object","errorCode":null,"errorMessage":"${context} must be an object","messagePattern":"(.+?) must be an object","errorType":"exception","errorClass":"ClaudeWebProtocolError","httpStatus":null,"severity":"error","filePath":"open-sse/executors/claude-web/stream.ts","lineNumber":174,"sourceCode":"  }\n  return undefined;\n}\n\nfunction projectMetadataEvent(\n  eventType: string,\n  event: Record<string, unknown>\n): Record<string, unknown> {\n  const projected: Record<string, unknown> = { type: eventType };\n  for (const field of METADATA_EVENT_FIELDS[eventType] ?? []) {\n    const value = safeMetadataValue(event[field]);\n    if (value !== undefined) projected[field] = value;\n  }\n  return projected;\n}\n\nfunction requireRecord(value: unknown, context: string): Record<string, unknown> {\n  if (!value || typeof value !== \"object\" || Array.isArray(value)) {\n    throw new ClaudeWebProtocolError(`${context} must be an object`);\n  }\n  return value as Record<string, unknown>;\n}\n\nfunction requireBlockIndex(event: Record<string, unknown>): number {\n  if (!Number.isInteger(event.index) || (event.index as number) < 0) {\n    throw new ClaudeWebProtocolError(\"Content block index is invalid\");\n  }\n  return event.index as number;\n}\n\nfunction deltaText(delta: Record<string, unknown>, fields: string[]): string {\n  for (const field of fields) {\n    const value = delta[field];\n    if (typeof value === \"string\") return value;\n  }\n  throw new ClaudeWebProtocolError(\"Content delta text is invalid\");\n}","sourceCodeStart":156,"sourceCodeEnd":192,"githubUrl":"https://github.com/diegosouzapw/OmniRoute/blob/a179ffed5bb2e0b883b9ae7214ce8717b2a94c4d/open-sse/executors/claude-web/stream.ts#L156-L192","documentation":"Generic shape guard requireRecord: a field expected to be a JSON object (e.g. message, content_block, or delta inside a Claude Web protocol event) is null, a non-object, or an array. The context string in the interpolated message names which field failed; the event came from upstream but does not match the expected protocol schema.","triggerScenarios":"Thrown at open-sse/executors/claude-web/stream.ts:174 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Inspect the context name in the thrown message to identify the malformed field and log the raw event for diagnosis","Treat as an upstream protocol change: end the stream cleanly rather than partially emitting","If claude.ai changed its event schema, update parseProtocolEvent/field expectations in stream.ts"],"exampleFix":null,"handlingStrategy":"type-guard","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"a179ffed5bb2e0b883b9ae7214ce8717b2a94c4d","analyzedAt":"2026-08-25T18:35:09.898Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}