odysseus-dev/odysseus · error · HTTPException
empty memory
Error message
empty memory
What it means
On POST /api/memory/add, the request's text field is stripped and, if empty, rejected with 400 'empty memory' before load/duplicate-check/add run. The endpoint accepts either a typed MemoryAddRequest body or falls back to reading Form fields (text, category, source, session_id), so whitespace-only or missing text in either shape triggers it.
Source
Thrown at routes/memory/memory_routes.py:120
request: Request,
memory_data: Optional[MemoryAddRequest] = None
):
"""Add a new memory entry with optional category, source, and session reference."""
from src.auth_helpers import require_privilege
require_privilege(request, "can_manage_memory")
if memory_data is None:
form = await request.form()
memory_data = MemoryAddRequest(
text=form.get("text"),
category=form.get("category", "fact"),
source=form.get("source", "user"),
session_id=form.get("session_id")
)
user = _owner(request)
text = (memory_data.text or "").strip()
if not text:
raise HTTPException(400, "empty memory")
user_mem = memory_manager.load(owner=user)
if memory_manager.find_duplicates(text, user_mem):
return {"ok": True, "count": len(user_mem), "message": "Memory already exists"}
if memory_data.session_id:
try:
session_obj = session_manager.get_session(memory_data.session_id)
except KeyError:
raise HTTPException(404, "Session not found")
_assert_session_owner(session_obj, user)
new_entry = memory_manager.add_entry(text, memory_data.source, memory_data.category, owner=user)
if memory_data.session_id:
new_entry["session_id"] = memory_data.session_id
all_mem = _load_for_update(memory_manager)
all_mem.append(new_entry)
memory_manager.save(all_mem)
# Sync vector indexView on GitHub (pinned to f9235ebbf1)
Solutions
- Validate client-side that text.strip() is non-empty before posting.
- Use the exact field name 'text' (Form fallback) or a well-formed MemoryAddRequest body.
- If the source produced nothing (empty transcript/extraction), skip the memory-add call entirely.
Example fix
# before
requests.post(f"{base}/api/memory/add", data={"text": memo or ""})
# after
if memo and memo.strip():
requests.post(f"{base}/api/memory/add", data={"text": memo.strip()}) Defensive patterns
Strategy: validation
Validate before calling
def memory_text_ok(text) -> bool:
return isinstance(text, str) and bool(text.strip()) Prevention
- Strip and check text client-side before posting.
- Use the exact field name 'text'.
- Skip the add call entirely when the upstream source produced no content.
When it happens
Trigger: Posting form data with text="" or " "; sending text as null in the JSON model; form-binding bug where the text input name is wrong (e.g. 'content' instead of 'text') so the field arrives empty.
Common situations: Frontend submitting before the textarea is filled; client field-name mismatch; automated memory writers emitting empty strings on parse failures.
Related errors
- Import failed: server returned ${res.status}
- command is required for stdio transport
- d && d.detail ? d.detail : ('HTTP ' + res.status)
- result.detail || 'Failed to rename session'
- Invalid backup file: ' + e.message
AI-assisted analysis of odysseus-dev/odysseus@f9235ebbf1 (2026-08-14).
Data as JSON: /api/errors/e37247289f2ef9a4.
Report an issue: GitHub.