{"record":{"id":"cad85ae77d291ce0","repo":"mem0ai/mem0","slug":"provide-text-or-metadata-to-update","errorCode":null,"errorMessage":"Provide text or metadata to update","messagePattern":"Provide text or metadata to update","errorType":"exception","errorClass":"NodeOperationError","httpStatus":null,"severity":"warning","filePath":"integrations/n8n-nodes-mem0/nodes/Mem0/Mem0.node.ts","lineNumber":550,"sourceCode":"\t\t\t\t\tconst memoryId = this.getNodeParameter('memoryId', i) as string;\n\t\t\t\t\tresponseData = await request('GET', `/v1/memories/${encodeURIComponent(memoryId)}/`);\n\t\t\t\t} else if (operation === 'update') {\n\t\t\t\t\tconst memoryId = this.getNodeParameter('memoryId', i) as string;\n\t\t\t\t\tconst body: IDataObject = {};\n\t\t\t\t\tconst text = this.getNodeParameter('text', i, '') as string;\n\t\t\t\t\tconst metadata = this.getNodeParameter('metadata', i, '') as string;\n\t\t\t\t\tif (text) body.text = text;\n\t\t\t\t\tif (metadata) {\n\t\t\t\t\t\ttry {\n\t\t\t\t\t\t\tbody.metadata = typeof metadata === 'string' ? JSON.parse(metadata) : metadata;\n\t\t\t\t\t\t} catch {\n\t\t\t\t\t\t\tthrow new NodeOperationError(this.getNode(), 'Invalid JSON in \"Metadata\" field', {\n\t\t\t\t\t\t\t\titemIndex: i,\n\t\t\t\t\t\t\t});\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\tif (Object.keys(body).length === 0) {\n\t\t\t\t\t\tthrow new NodeOperationError(this.getNode(), 'Provide text or metadata to update', {\n\t\t\t\t\t\t\titemIndex: i,\n\t\t\t\t\t\t});\n\t\t\t\t\t}\n\t\t\t\t\tresponseData = await request('PUT', `/v1/memories/${encodeURIComponent(memoryId)}/`, body);\n\t\t\t\t} else if (operation === 'delete') {\n\t\t\t\t\tconst memoryId = this.getNodeParameter('memoryId', i) as string;\n\t\t\t\t\tresponseData = await request('DELETE', `/v1/memories/${encodeURIComponent(memoryId)}/`);\n\t\t\t\t}\n\n\t\t\t\tconst arr = Array.isArray(responseData) ? responseData : [responseData];\n\t\t\t\tfor (const entry of arr) {\n\t\t\t\t\treturnData.push({ json: entry, pairedItem: { item: i } });\n\t\t\t\t}\n\t\t\t} catch (error) {\n\t\t\t\tif (this.continueOnFail()) {\n\t\t\t\t\treturnData.push({ json: { error: (error as Error).message }, pairedItem: { item: i } });\n\t\t\t\t\tcontinue;\n\t\t\t\t}","sourceCodeStart":532,"sourceCodeEnd":568,"githubUrl":"https://github.com/mem0ai/mem0/blob/001c235229be8795e3834520467bd0d661ed8f34/integrations/n8n-nodes-mem0/nodes/Mem0/Mem0.node.ts#L532-L568","documentation":"DELETE /api-keys/{key_id} parses key_id as a UUID; anything that is not a valid UUID string raises 404 (not 422) from the except branch. This intentionally makes malformed IDs indistinguishable from missing keys so the endpoint does not leak which key IDs exist.","triggerScenarios":"Calling DELETE /api-keys/my-key, /api-keys/123, or with a truncated UUID (35 chars); passing the key prefix or the raw API key value instead of the key record's id; URL-encoding issues that mangle the UUID.","commonSituations":"Confusing the key's id (returned in the listing/creation response) with the key material or its prefix; hand-building the URL and dropping a character; frontend storing label instead of id.","solutions":["Use the id field from the POST /api-keys creation response or GET /api-keys listing (a full UUID like '3fa85f64-5717-4562-b3fc-2c963f66afa6').","Validate client-side that key_id matches a UUID pattern before issuing the DELETE.","If your stored id is shorter, you saved the wrong field — re-fetch the key list."],"exampleFix":"# before\nrequests.delete(f\"{BASE}/api-keys/{key_prefix}\", headers=h)  # 404\n\n# after\nkeys = requests.get(f\"{BASE}/api-keys\", headers=h).json()\nkey_id = next(k[\"id\"] for k in keys if k[\"label\"] == \"ci-bot\")\nrequests.delete(f\"{BASE}/api-keys/{key_id}\", headers=h)","handlingStrategy":"type-guard","validationCode":"import uuid\n\ndef is_uuid(value: str) -> bool:\n    try:\n        uuid.UUID(value)\n        return True\n    except (TypeError, ValueError):\n        return False\n\nassert is_uuid(key_id), f\"key_id must be a UUID, got {key_id!r}\"","typeGuard":"def is_key_id(value: str) -> bool:\n    \"\"\"True when value is a valid UUID string usable as an API key id.\"\"\"\n    try:\n        uuid.UUID(str(value))\n        return True\n    except (TypeError, ValueError):\n        return False","tryCatchPattern":null,"preventionTips":["Store key ids from the creation response, never prefixes or labels.","Validate UUID format client-side before DELETE calls.","Log which field was used so mis-ids are obvious in diagnostics."],"tags":["api-key","http-404","validation","rest-server"],"backgroundTag":null,"analyzedSha":"001c235229be8795e3834520467bd0d661ed8f34","analyzedAt":"2026-08-15T01:55:42.685Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}