Skip to content

Instantly share code, notes, and snippets.

@BexTuychiev
Created February 19, 2026 23:31
Show Gist options
  • Select an option

  • Save BexTuychiev/f712a1bb6cc773a8876a47933993ad08 to your computer and use it in GitHub Desktop.

Select an option

Save BexTuychiev/f712a1bb6cc773a8876a47933993ad08 to your computer and use it in GitHub Desktop.
PUT /memories/{id} bug report for mem0 self-hosted server

PUT /memories/{id} Bug Report

Setup

The bug shows up on the self-hosted Docker deployment described in the article. The stack uses three containers:

  • mem0/mem0-api-server:latest (mem0ai v0.1.117 at time of testing)
  • ankane/pgvector:v0.5.1
  • neo4j:5.26.4

The official image is missing a few runtime dependencies, so the Dockerfile installs them on top:

FROM mem0/mem0-api-server:latest
RUN pip install --no-cache-dir "psycopg[binary,pool]" "mem0ai[graph]" rank-bm25 langchain-neo4j neo4j

The full docker-compose.yaml is here: https://gist.github.com/BexTuychiev/2597529900335a66265dff5955f1cebf

Once the three files (.env, Dockerfile, docker-compose.yaml) are in place:

docker compose up -d --build

Wait for all three containers to report healthy, then confirm the API responds:

curl -s http://localhost:8888/
# Should return a 307 redirect to /docs

Reproducing the error

Step 1: Add a memory

curl -s -X POST http://localhost:8888/memories \
  -H "Content-Type: application/json" \
  -d '{
    "messages": [{"role": "user", "content": "I love hiking in the Rockies."}],
    "user_id": "test_user"
  }'

Grab one of the memory IDs from the response.

Step 2: Try updating it with PUT

curl -s -X PUT http://localhost:8888/memories/<memory_id> \
  -H "Content-Type: application/json" \
  -d '{"text": "Loves hiking in Colorado"}'

Response:

{"detail": "'dict' object has no attribute 'replace'"}

HTTP status: 500. The request body field name doesn't matter. {"text": "..."}, {"memory": "..."}, {"data": "..."} all produce the same error.

Server-side traceback

File "/app/main.py", line 164, in update_memory
    return MEMORY_INSTANCE.update(memory_id=memory_id, data=updated_memory)
File "/usr/local/lib/python3.12/site-packages/mem0/memory/main.py", line 746, in update
    existing_embeddings = {data: self.embedding_model.embed(data, "update")}
File "/usr/local/lib/python3.12/site-packages/mem0/embeddings/openai.py", line 44, in embed
    text = text.replace("\n", " ")
AttributeError: 'dict' object has no attribute 'replace'

Root cause

The FastAPI handler in /app/main.py declares the parameter as a dict:

@app.put("/memories/{memory_id}", summary="Update a memory")
def update_memory(memory_id: str, updated_memory: Dict[str, Any]):
    ...
    return MEMORY_INSTANCE.update(memory_id=memory_id, data=updated_memory)

But Memory.update() expects data to be a plain string:

def update(self, memory_id, data):
    # data (str): New content to update the memory with.
    existing_embeddings = {data: self.embedding_model.embed(data, "update")}

The handler passes the parsed JSON body (a dict) straight into Memory.update(), which hands it to the embedding model. The embedding model calls .replace("\n", " ") on it, and that fails because dicts don't have a .replace() method.

Version info

  • mem0ai: 0.1.117
  • mem0/mem0-api-server: latest tag as of Feb 19, 2026
  • Python: 3.12 (inside the container)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment