Mintplex-Labs/anything-llm · warning
Empty entry
Error message
Empty entry
What it means
Returned (HTTP 400) by POST /api/memories in the memory-manager when req.body.entry is missing, empty, or whitespace-only after trim. Entries are appended to MEMORY.md joined by a '§' delimiter, and blank entries would corrupt that delimiter-split format and pollute the agent's memory context, so the check is strict and rejects the whole request before reading or writing the file.
Source
Thrown at open-computer/services/memory-manager/server.js:60
return { chars: raw.length, exists: true };
} catch {
return { chars: 0, exists: false };
}
}
// --- API Routes ---
app.get("/api/memories", (_req, res) => {
res.json({ entries: readEntries(MEMORY_FILE) });
});
app.get("/api/user", (_req, res) => {
res.json({ entries: readEntries(USER_FILE) });
});
app.post("/api/memories", (req, res) => {
const { entry } = req.body;
if (!entry || !entry.trim()) return res.status(400).json({ error: "Empty entry" });
const entries = readEntries(MEMORY_FILE);
entries.push(entry.trim());
const combined = entries.join(` ${DELIMITER} `);
if (combined.length > CHAR_LIMIT) {
return res.status(400).json({ error: `Would exceed ${CHAR_LIMIT} char limit` });
}
writeEntries(MEMORY_FILE, entries);
res.json({ entries });
});
app.delete("/api/memories/:index", (req, res) => {
const entries = readEntries(MEMORY_FILE);
const idx = parseInt(req.params.index, 10);
if (idx < 0 || idx >= entries.length) return res.status(404).json({ error: "Not found" });
entries.splice(idx, 1);
writeEntries(MEMORY_FILE, entries);
res.json({ entries });
});View on GitHub (pinned to 3aec848f28)
Solutions
- Trim the entry client-side and skip the POST when the result is empty
- Send exactly {entry: string} as JSON with Content-Type: application/json
- If the body field is named differently in your caller, map it to entry before posting
Example fix
// before
await fetch(`${BASE}/api/memories`, {
method: 'POST', body: JSON.stringify({entry: userInput}),
}); // 400 when userInput is '' or spaces
// after
const entry = (userInput || '').trim();
if (!entry) return; // nothing durable to remember
await fetch(`${BASE}/api/memories`, {
method: 'POST',
headers: {'Content-Type': 'application/json'},
body: JSON.stringify({entry}),
}); Defensive patterns
Strategy: validation
Validate before calling
const entry = (req?.body?.entry ?? '').trim();
if (!entry) { /* skip the POST entirely */ } Type guard
function isNonEmptyEntry(body) {
return typeof body?.entry === 'string' && body.entry.trim().length > 0;
} Prevention
- Trim user input and early-return on empty before calling POST /api/memories
- Always send Content-Type: application/json with {entry: string}
- Disable save buttons while the textarea is whitespace-only
When it happens
Trigger: POST /api/memories with {entry: ''}, {entry: ' \t'}, or a body missing the entry key entirely; sending a JSON body without Content-Type: application/json so express.json() never parses it and entry is undefined; sending {text: '...'} or {memory: '...'} instead of the expected field name.
Common situations: UI save button wired to an empty textarea; automation scripts guessing the wrong body field; whitespace-only pastes; missing JSON content-type header in hand-rolled curl/fetch calls.
Related errors
- Would exceed ${CHAR_LIMIT} char limit
- The native whisper model failed to download from the hugging
- HTTP ${res.status}: ${res.statusText}
- res.statusText || "Error fetching api keys."
- res.statusText || "Error generating api key."
AI-assisted analysis of Mintplex-Labs/anything-llm@3aec848f28 (2026-08-18).
Data as JSON: /api/errors/8111b2abcde4ee3d.
Report an issue: GitHub.