{"record":{"id":"2f69bc4bfbaf703f","repo":"thedotmack/claude-mem","slug":"observation-record-event-eventtype-is-required","errorCode":null,"errorMessage":"observation_record_event: \"eventType\" is required","messagePattern":"observation_record_event: \"eventType\" is required","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/servers/mcp-server.ts","lineNumber":277,"sourceCode":"  serverSessionId?: string | null;\n  contentSessionId?: string | null;\n  memorySessionId?: string | null;\n  platformSource?: string | null;\n  sourceType?: 'hook' | 'worker' | 'provider' | 'server' | 'api';\n  eventType: string;\n  payload?: unknown;\n  occurredAtEpoch?: number;\n  generate?: boolean;\n}\n\nfunction normalizeMcpPlatformSource(value: string | null): string | null {\n  return typeof value === 'string' ? normalizePlatformSource(value) : null;\n}\n\nconst handleObservationRecordEvent = wrapHandler('observation_record_event', async (args: ObservationRecordEventArgs) => {\n  const ctx = requireServerForObservationTool('observation_record_event');\n  if (typeof args?.eventType !== 'string' || args.eventType.trim().length === 0) {\n    throw new Error('observation_record_event: \"eventType\" is required');\n  }\n  const projectId = args.projectId && args.projectId.trim().length > 0 ? args.projectId : ctx.projectId;\n  const request: ServerRecordEventRequest = {\n    projectId,\n    sourceType: args.sourceType ?? 'api',\n    eventType: args.eventType,\n    occurredAtEpoch: typeof args.occurredAtEpoch === 'number' ? args.occurredAtEpoch : Date.now(),\n    ...(args.serverSessionId !== undefined ? { serverSessionId: args.serverSessionId } : {}),\n    ...(args.contentSessionId !== undefined ? { contentSessionId: args.contentSessionId } : {}),\n    ...(args.memorySessionId !== undefined ? { memorySessionId: args.memorySessionId } : {}),\n    ...(args.platformSource !== undefined ? { platformSource: normalizeMcpPlatformSource(args.platformSource) } : {}),\n    ...(args.payload !== undefined ? { payload: args.payload } : {}),\n    ...(args.generate !== undefined ? { generate: args.generate } : {}),\n  };\n  const response = await ctx.client.recordEvent(request);\n  return formatJsonResult(response);\n});\n","sourceCodeStart":259,"sourceCodeEnd":295,"githubUrl":"https://github.com/thedotmack/claude-mem/blob/d768ba364302d12b76e69e4f021f0bb1d2d50ed6/src/servers/mcp-server.ts#L259-L295","documentation":"Validation error inside the observation_record_event tool handler. After the server-runtime guard passes, the handler requires args.eventType to be a non-empty trimmed string and throws this plain Error if it is missing or blank. This runs before the event is sent to /v1/events, so no network call is made on failure.","triggerScenarios":"Calling observation_record_event with eventType omitted, null, non-string, or whitespace-only. Common when the caller passes payload/platformSource but forgets the discriminating event type.","commonSituations":"Automation mirrors a hook event but forgets the eventType field; an LLM client passes { sourceType: 'hook' } only; eventType comes from a variable that was undefined; caller confused record_event (typed event) with observation_add (free content).","solutions":["Supply a non-empty eventType string (e.g. 'session.start', 'tool.call').","If you intended to write free-text memory, use observation_add with content instead.","Validate eventType is a non-empty string on the client before invoking the tool."],"exampleFix":"// before\nawait tools.observation_record_event({\n  sourceType: 'hook',\n  payload: { tool: 'Edit' },\n});\n// throws 'observation_record_event: \"eventType\" is required'\n\n// after\nawait tools.observation_record_event({\n  eventType: 'tool.call',\n  sourceType: 'hook',\n  payload: { tool: 'Edit' },\n});","handlingStrategy":"validation","validationCode":"if (typeof args?.eventType !== 'string' || args.eventType.trim().length === 0) {\n  return { content: [{ type: 'text', text: 'eventType is required' }], isError: true };\n}","typeGuard":"function hasEventType(v: unknown): v is { eventType: string } {\n  return typeof (v as any)?.eventType === 'string' && (v as any).eventType.trim().length > 0;\n}","tryCatchPattern":null,"preventionTips":["Always pair an eventType with the event payload; document a list of known event types.","Validate eventType is a non-empty string client-side.","Use record_event for typed events and observation_add for free text — do not mix."],"tags":["mcp","validation","observation-tools","events"],"backgroundTag":null,"analyzedSha":"d768ba364302d12b76e69e4f021f0bb1d2d50ed6","analyzedAt":"2026-08-12T23:52:55.241Z","schemaVersion":2},"datasetVersion":"2026-08-13T04:17:16.726Z"}