Skip to content

[Bug]: Adding memories to a just-deleted project returns 500: SessionDeletedError is not mapped to an HTTP status #1770

Description

@wanghy73

Describe the bug

POST /api/v2/memories to a project that has just been deleted (or whose deletion is racing the add) returns 500.

SessionDeletedError is raised in packages/server/src/memmachine_server/episodic_memory/episodic_memory_manager.py (lines 156 and 266), but server/api_v2/exceptions.py maps only SessionNotFoundError, and add_memories (server/api_v2/router.py) catches nothing, so the error reaches the client as an unhandled 500.

Steps to reproduce

POST /api/v2/projects/delete  {"org_id": "o", "project_id": "p"}   -> 204
POST /api/v2/memories         {"org_id": "o", "project_id": "p", "messages": [...]}   -> 500

Server log: SessionDeletedError: Session 'o/p' has been deleted.

Expected behavior

A mapped client error: 404 (the project no longer exists, as after the purge completes) or 409/503 (it is being deleted).

Environment

  • OS: Linux (Ubuntu 24.04), Docker
  • MemMachine Version: main at c99bc0e (0.3.9+50.gc99bc0e), image built from source; also seen at c08cf26
  • Development language version: Python 3.12 (in the image)
  • Backend: event memory, PostgreSQL 18, Qdrant 1.19.1

Additional context

Suggested fix: map SessionDeletedError in exceptions.py alongside SessionNotFoundError.

Activity

  1. added theissue type on Oct 6, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions