Mintplex-Labs/anything-llm · warning
Content must be a non-empty string
Error message
Content must be a non-empty string
What it means
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.
Source
Thrown at server/endpoints/memory.js:116
);
app.put(
"/memories/:memoryId",
[
validatedRequest,
flexUserRoleValid([ROLES.all]),
memoryFeatureEnabled,
validateMemoryOwner,
],
async (request, response) => {
try {
const memoryId = Number(request.params.memoryId);
const { content } = reqBody(request);
const { memory, message } = await Memory.update(memoryId, {
content: content.trim(),
});
if (!memory) return response.status(400).json({ error: message });
response.status(200).json({ memory });
} catch (e) {
console.error(e);
return response.sendStatus(500);
}
}
);
app.delete(
"/memories/:memoryId",
[
validatedRequest,
flexUserRoleValid([ROLES.all]),
memoryFeatureEnabled,
validateMemoryOwner,
],
async (request, response) => {
try {View on GitHub (pinned to 3aec848f28)
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
Example fix
// before
await fetch(`/memories/${id}`, { method: 'PUT', body: JSON.stringify({ content: input }) });
// after
if (typeof input !== 'string' || input.trim().length === 0) throw new Error('content must be a non-empty string');
await fetch(`/memories/${id}`, { method: 'PUT', headers: {'Content-Type': 'application/json'}, body: JSON.stringify({ content: input }) }); Defensive patterns
Strategy: type-guard
Validate before calling
const content = typeof input === 'string' ? input.trim() : '';
if (content.length === 0) { disableSave(); return; } // block the PUT entirely Type guard
function isNonEmptyContent(v) {
return typeof v === 'string' && v.trim().length > 0;
} Prevention
- 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
When it happens
Trigger: PUT /memories/:id with content missing, null/undefined/number, or whitespace-only (it is .trim()'d in the handler before validation, so ' ' fails).
Common situations: Client sending {text} or {value} instead of {content}; submitting an empty textarea; JSON body built with content: '' by a form reset.
Understand the failure class
Background: Schema validation failed / invalid input schema: payload rejected because its shape doesn't match the expected schema — this error's family across 28 libraries.
Related errors
- Invalid scope: ${JSON.stringify(v)}
- Content must be a non-empty string
- Name and config are required
- Query parameter cannot be empty.
- Message is empty
AI-assisted analysis of Mintplex-Labs/anything-llm@3aec848f28 (2026-08-18).
Data as JSON: /api/errors/4c2754154316501a.
Report an issue: GitHub.