{"record":{"id":"769e7fa0701ea08d","repo":"thedotmack/claude-mem","slug":"observation-add-content-is-required","errorCode":null,"errorMessage":"observation_add: \"content\" is required","messagePattern":"observation_add: \"content\" is required","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"src/servers/mcp-server.ts","lineNumber":246,"sourceCode":"      return formatToolError(error);\n    }\n  };\n}\n\ninterface ObservationAddArgs {\n  projectId?: string;\n  serverSessionId?: string | null;\n  contentSessionId?: string | null;\n  platformSource?: string | null;\n  kind?: string;\n  content: string;\n  metadata?: Record<string, unknown>;\n}\n\nconst handleObservationAdd = wrapHandler('observation_add', async (args: ObservationAddArgs) => {\n  const ctx = requireServerForObservationTool('observation_add');\n  if (typeof args?.content !== 'string' || args.content.trim().length === 0) {\n    throw new Error('observation_add: \"content\" is required');\n  }\n  const projectId = args.projectId && args.projectId.trim().length > 0 ? args.projectId : ctx.projectId;\n  const request: ServerAddObservationRequest = {\n    projectId,\n    content: args.content,\n    ...(args.serverSessionId !== undefined ? { serverSessionId: args.serverSessionId } : {}),\n    ...(args.contentSessionId !== undefined ? { contentSessionId: args.contentSessionId } : {}),\n    ...(args.platformSource !== undefined ? { platformSource: args.platformSource } : {}),\n    ...(args.kind !== undefined ? { kind: args.kind } : {}),\n    ...(args.metadata !== undefined ? { metadata: args.metadata } : {}),\n  };\n  const response = await ctx.client.addObservation(request);\n  return formatJsonResult(response);\n});\n\ninterface ObservationRecordEventArgs {\n  projectId?: string;\n  serverSessionId?: string | null;","sourceCodeStart":228,"sourceCodeEnd":264,"githubUrl":"https://github.com/thedotmack/claude-mem/blob/d8bc9755e74915e5c3b999181e10a67c889bce2a/src/servers/mcp-server.ts#L228-L264","documentation":"handleObservationAdd validates its arguments before forwarding to the server: the 'content' field must be a non-empty, non-whitespace string. If it's missing, not a string, or blank after trimming, the handler throws `observation_add: \"content\" is required`, which wrapHandler converts into an MCP error result. It's a plain argument-validation error on the tool's input schema.","triggerScenarios":"Calling the observation_add MCP tool with args omitted, args.content undefined/null/non-string, or args.content set to \"\" or whitespace-only (e.g. \"   \").","commonSituations":"An agent constructing the tool call with an empty variable because upstream extraction found nothing; JSON payloads where content sits under a different key (e.g. 'text' or 'observation'); programmatic callers passing a number/object instead of a string; template rendering leaving the field blank.","solutions":["Pass a non-empty string in the `content` field of the observation_add arguments.","Trim-check the value client-side before calling the tool; skip the call when empty.","Verify the payload key is exactly `content` (not `text`/`observation`) and that it's a string, not a number or object.","If content comes from an upstream step, guard that step's output so empty results don't produce the tool call."],"exampleFix":"// before\nawait observation_add({ projectId: 'p1' });\n// after\nconst content = extractedNote.trim();\nif (content) await observation_add({ projectId: 'p1', content });","handlingStrategy":"validation","validationCode":"function canCallObservationAdd(args: { content?: unknown } | undefined): args is { content: string } {\n  return typeof args?.content === 'string' && args.content.trim().length > 0;\n}","typeGuard":"function hasNonEmptyContent(args: unknown): args is { content: string } {\n  return typeof args === 'object' && args !== null\n    && 'content' in args\n    && typeof (args as { content: unknown }).content === 'string'\n    && (args as { content: string }).content.trim().length > 0;\n}","tryCatchPattern":"try {\n  await observation_add(args);\n} catch (err) {\n  if ((err as Error).message === 'observation_add: \"content\" is required') {\n    // skip or queue the observation; do not retry with the same payload\n  }\n}","preventionTips":["Validate that the payload key is exactly `content` and is a trimmed non-empty string before invoking the tool.","Guard upstream extraction steps so empty results never emit an observation_add call.","Coerce non-string values (numbers, objects) to string or reject them at the call site.","Add a JSON-schema enforcement layer for tool arguments in agent frameworks."],"tags":["validation","mcp","arguments","tools"],"backgroundTag":"missing-required-argument","analyzedSha":"d8bc9755e74915e5c3b999181e10a67c889bce2a","analyzedAt":"2026-09-17T16:40:26.182Z","contentChangedAt":"2026-09-17T16:40:26.182Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}