{"record":{"id":"8111b2abcde4ee3d","repo":"Mintplex-Labs/anything-llm","slug":"empty-entry","errorCode":null,"errorMessage":"Empty entry","messagePattern":"Empty entry","errorType":"http","errorClass":null,"httpStatus":400,"severity":"warning","filePath":"open-computer/services/memory-manager/server.js","lineNumber":60,"sourceCode":"    return { chars: raw.length, exists: true };\n  } catch {\n    return { chars: 0, exists: false };\n  }\n}\n\n// --- API Routes ---\n\napp.get(\"/api/memories\", (_req, res) => {\n  res.json({ entries: readEntries(MEMORY_FILE) });\n});\n\napp.get(\"/api/user\", (_req, res) => {\n  res.json({ entries: readEntries(USER_FILE) });\n});\n\napp.post(\"/api/memories\", (req, res) => {\n  const { entry } = req.body;\n  if (!entry || !entry.trim()) return res.status(400).json({ error: \"Empty entry\" });\n  const entries = readEntries(MEMORY_FILE);\n  entries.push(entry.trim());\n  const combined = entries.join(` ${DELIMITER} `);\n  if (combined.length > CHAR_LIMIT) {\n    return res.status(400).json({ error: `Would exceed ${CHAR_LIMIT} char limit` });\n  }\n  writeEntries(MEMORY_FILE, entries);\n  res.json({ entries });\n});\n\napp.delete(\"/api/memories/:index\", (req, res) => {\n  const entries = readEntries(MEMORY_FILE);\n  const idx = parseInt(req.params.index, 10);\n  if (idx < 0 || idx >= entries.length) return res.status(404).json({ error: \"Not found\" });\n  entries.splice(idx, 1);\n  writeEntries(MEMORY_FILE, entries);\n  res.json({ entries });\n});","sourceCodeStart":42,"sourceCodeEnd":78,"githubUrl":"https://github.com/Mintplex-Labs/anything-llm/blob/3aec848f2885144aa8f1e53b9731a04310d5d558/open-computer/services/memory-manager/server.js#L42-L78","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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"],"exampleFix":"// before\nawait fetch(`${BASE}/api/memories`, {\n  method: 'POST', body: JSON.stringify({entry: userInput}),\n}); // 400 when userInput is '' or spaces\n\n// after\nconst entry = (userInput || '').trim();\nif (!entry) return; // nothing durable to remember\nawait fetch(`${BASE}/api/memories`, {\n  method: 'POST',\n  headers: {'Content-Type': 'application/json'},\n  body: JSON.stringify({entry}),\n});","handlingStrategy":"validation","validationCode":"const entry = (req?.body?.entry ?? '').trim();\nif (!entry) { /* skip the POST entirely */ }","typeGuard":"function isNonEmptyEntry(body) {\n  return typeof body?.entry === 'string' && body.entry.trim().length > 0;\n}","tryCatchPattern":null,"preventionTips":["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"],"tags":["http-400","request-validation","memory-manager","empty-input"],"backgroundTag":"request-validation-failed","analyzedSha":"3aec848f2885144aa8f1e53b9731a04310d5d558","analyzedAt":"2026-08-18T10:02:21.017Z","contentChangedAt":"2026-08-18T10:02:21.017Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}