{"record":{"id":"6786ab5da1cf7df1","repo":"mem0ai/mem0","slug":"at-least-one-of-text-metadata-or-expirationdate","errorCode":null,"errorMessage":"At least one of text, metadata, or expirationDate must be provided.","messagePattern":"At least one of text, metadata, or expirationDate must be provided\\.","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"mem0-ts/src/oss/src/memory/index.ts","lineNumber":1675,"sourceCode":"\n    const options: UpdateMemoryOptions =\n      typeof config === \"string\" ? { text: config } : config;\n\n    const { data, metadata, expirationDate } = options;\n    let text = options.text;\n\n    if (data != null) {\n      logger.warn(\n        \"The `data` option of update() is deprecated and will be removed in \" +\n          \"the next major release. Use `text` instead.\",\n      );\n      if (text == null) {\n        text = data;\n      }\n    }\n\n    if (text == null && metadata == null && expirationDate === undefined) {\n      throw new Error(\n        \"At least one of text, metadata, or expirationDate must be provided.\",\n      );\n    }\n\n    const updateMetadata: Record<string, any> = { ...metadata };\n    if (expirationDate !== undefined) {\n      updateMetadata.expiration_date =\n        expirationDate === null\n          ? null\n          : normalizeExpirationDate(expirationDate);\n    }\n\n    const existingEmbeddings: Record<string, number[]> = {};\n    if (text != null) {\n      existingEmbeddings[text] = await this.embedder.embed(text, \"update\");\n    }\n\n    await this.updateMemory(memoryId, text, existingEmbeddings, updateMetadata);","sourceCodeStart":1657,"sourceCodeEnd":1693,"githubUrl":"https://github.com/mem0ai/mem0/blob/001c235229be8795e3834520467bd0d661ed8f34/mem0-ts/src/oss/src/memory/index.ts#L1657-L1693","documentation":"Thrown by Memory.update() when none of text, metadata, or expirationDate is supplied. update() supports text-only, metadata-only, and expiration-only updates (a metadata-only update re-indexes the stored text), so it needs to know at least what to change. The deprecated data option is treated as text if text is absent, so passing only data does NOT trigger this.","triggerScenarios":"Calling memory.update(memoryId, {}) — no text, metadata null, expirationDate undefined. Also update(memoryId, { metadata: undefined }) since undefined fails the null/undefined checks.","commonSituations":"Building the update payload dynamically and all fields end up undefined; calling update just to 'touch' a memory (not supported); migrating from an older API shape where an empty body was a no-op.","solutions":["Pass at least one field: memory.update(id, { text: 'new value' }) or { metadata: {...} } or { expirationDate: '2026-12-31' }","Filter undefined keys out of the payload before calling: Object.fromEntries(Object.entries(opts).filter(([, v]) => v !== undefined))","If you only want to change expiry, pass expirationDate (null clears it) — text and metadata can stay omitted"],"exampleFix":"// before\nawait memory.update(memoryId, updatePayload); // all fields undefined\n\n// after\nconst payload = Object.fromEntries(\n  Object.entries(updatePayload).filter(([, v]) => v !== undefined),\n);\nif (Object.keys(payload).length) {\n  await memory.update(memoryId, payload);\n}","handlingStrategy":"validation","validationCode":"const patch = Object.fromEntries(\n  Object.entries(opts).filter(([, v]) => v !== undefined),\n);\nif (!('text' in patch) && !('metadata' in patch) && !('expirationDate' in patch)) {\n  throw new Error('update() needs text, metadata, or expirationDate');\n}\nawait memory.update(id, patch);","typeGuard":"const isUpdatePayload = (p: unknown): p is { text?: string; metadata?: Record<string, unknown>; expirationDate?: string | null } =>\n  typeof p === 'object' && p !== null &&\n  ('text' in p || 'metadata' in p || 'expirationDate' in p);","tryCatchPattern":null,"preventionTips":["Strip undefined keys from dynamically built payloads before calling update()","Remember the deprecated data option still counts as text and suppresses this error"],"tags":["validation","oss","memory-update"],"backgroundTag":null,"analyzedSha":"001c235229be8795e3834520467bd0d661ed8f34","analyzedAt":"2026-08-15T01:55:42.685Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}