{"record":{"id":"4c2754154316501a","repo":"Mintplex-Labs/anything-llm","slug":"content-must-be-a-non-empty-string-4c2754","errorCode":null,"errorMessage":"Content must be a non-empty string","messagePattern":"Content must be a non-empty string","errorType":"http","errorClass":null,"httpStatus":400,"severity":"warning","filePath":"server/endpoints/memory.js","lineNumber":116,"sourceCode":"  );\n\n  app.put(\n    \"/memories/:memoryId\",\n    [\n      validatedRequest,\n      flexUserRoleValid([ROLES.all]),\n      memoryFeatureEnabled,\n      validateMemoryOwner,\n    ],\n    async (request, response) => {\n      try {\n        const memoryId = Number(request.params.memoryId);\n        const { content } = reqBody(request);\n        const { memory, message } = await Memory.update(memoryId, {\n          content: content.trim(),\n        });\n\n        if (!memory) return response.status(400).json({ error: message });\n        response.status(200).json({ memory });\n      } catch (e) {\n        console.error(e);\n        return response.sendStatus(500);\n      }\n    }\n  );\n\n  app.delete(\n    \"/memories/:memoryId\",\n    [\n      validatedRequest,\n      flexUserRoleValid([ROLES.all]),\n      memoryFeatureEnabled,\n      validateMemoryOwner,\n    ],\n    async (request, response) => {\n      try {","sourceCodeStart":98,"sourceCodeEnd":134,"githubUrl":"https://github.com/Mintplex-Labs/anything-llm/blob/3aec848f2885144aa8f1e53b9731a04310d5d558/server/endpoints/memory.js#L98-L134","documentation":"400 from PUT /memories/:memoryId. Memory.update runs validations.content, which throws 'Content must be a non-empty string' when content is not a string or trims to empty; the model catches and returns {memory:null, message}, surfaced by the endpoint as 400.","triggerScenarios":"PUT /memories/:id with content missing, null/undefined/number, or whitespace-only (it is .trim()'d in the handler before validation, so '   ' fails).","commonSituations":"Client sending {text} or {value} instead of {content}; submitting an empty textarea; JSON body built with content: '' by a form reset.","solutions":["Send JSON {content: '<non-empty string>'} on the PUT","Trim client-side and disable submit while the field is empty","Guard with a typeof check before issuing the request"],"exampleFix":"// before\nawait fetch(`/memories/${id}`, { method: 'PUT', body: JSON.stringify({ content: input }) });\n// after\nif (typeof input !== 'string' || input.trim().length === 0) throw new Error('content must be a non-empty string');\nawait fetch(`/memories/${id}`, { method: 'PUT', headers: {'Content-Type': 'application/json'}, body: JSON.stringify({ content: input }) });","handlingStrategy":"type-guard","validationCode":"const content = typeof input === 'string' ? input.trim() : '';\nif (content.length === 0) { disableSave(); return; } // block the PUT entirely","typeGuard":"function isNonEmptyContent(v) {\n  return typeof v === 'string' && v.trim().length > 0;\n}","tryCatchPattern":null,"preventionTips":["Send the exact field name {content}, not text/value","Trim and length-check before enabling submit","Reject non-string types client-side — the server validation is type-based, not just emptiness"],"tags":["memory","validation","http-400"],"backgroundTag":"schema-validation-failed","analyzedSha":"3aec848f2885144aa8f1e53b9731a04310d5d558","analyzedAt":"2026-08-18T10:02:21.017Z","schemaVersion":2},"datasetVersion":"2026-08-21T13:17:26.733Z"}