Bug: InMemory and SQLite backends require resource_id but create_memory_item() doesn't provide it
Summary
InMemoryMemoryItemRepository.create_item() and SQLiteMemoryItemRepository.create_item() require a mandatory resource_id parameter, but CRUDMixin._patch_create_memory_item() in crud.py doesn't provide it when calling create_item(). This causes a runtime error when trying to create memory items using InMemory or SQLite backends.
Version Information
- memU version: 1.4.0 (commit: 777f1ed)
- Python version: 3.13.12
- Database backends affected: InMemory, SQLite
Steps to Reproduce
from memu.app import MemoryService
memory_service = MemoryService(
llm_profiles={"default": {...}},
memorize_config={"memory_categories": [...]},
)
# This will fail with InMemory or SQLite backend
await memory_service.create_memory_item(
memory_type="event",
memory_content="Test message",
memory_categories=["Conversations"],
)
Error Message
TypeError: InMemoryMemoryItemRepository.create_item() missing 1 required keyword-only argument: 'resource_id'
Root Cause
In src/memu/app/crud.py:512-517, the _patch_create_memory_item() method calls:
item = store.memory_item_repo.create_item(
memory_type=memory_payload["type"],
summary=memory_payload["content"],
embedding=content_embedding,
user_data=dict(user or {}),
)
# Missing resource_id parameter!
However, the method signatures differ across backends:
PostgreSQL (Fixed in PR #232)
def create_item(
self,
*,
resource_id: str | None = None, # ✓ Optional
...
)
InMemory & SQLite (Still broken)
def create_item(
self,
*,
resource_id: str, # ✗ Required
...
)
Expected Behavior
All database backends should have consistent signatures. Since create_memory_item() API doesn't expose resource_id to users, the backends should make it optional (like PostgreSQL was fixed in #232).
Actual Behavior
InMemory and SQLite backends throw a TypeError because resource_id is required but not provided.
Possible Solutions
-
Make resource_id optional in InMemory and SQLite backends (recommended)
- Change
resource_id: str to resource_id: str | None = None
- Consistent with PostgreSQL backend
- Maintains backward compatibility
-
Pass a default resource_id in crud.py
- Less ideal as it doesn't address the inconsistency
Related Issues/PRs
Additional Context
This affects all users who want to use InMemory or SQLite backends with the create_memory_item() API, which is the standard flow for creating memories through the MemoryService interface.
Bug: InMemory and SQLite backends require
resource_idbutcreate_memory_item()doesn't provide itSummary
InMemoryMemoryItemRepository.create_item()andSQLiteMemoryItemRepository.create_item()require a mandatoryresource_idparameter, butCRUDMixin._patch_create_memory_item()incrud.pydoesn't provide it when callingcreate_item(). This causes a runtime error when trying to create memory items using InMemory or SQLite backends.Version Information
Steps to Reproduce
Error Message
Root Cause
In
src/memu/app/crud.py:512-517, the_patch_create_memory_item()method calls:However, the method signatures differ across backends:
PostgreSQL (Fixed in PR #232)
InMemory & SQLite (Still broken)
Expected Behavior
All database backends should have consistent signatures. Since
create_memory_item()API doesn't exposeresource_idto users, the backends should make it optional (like PostgreSQL was fixed in #232).Actual Behavior
InMemory and SQLite backends throw a TypeError because
resource_idis required but not provided.Possible Solutions
Make
resource_idoptional in InMemory and SQLite backends (recommended)resource_id: strtoresource_id: str | None = NonePass a default
resource_idincrud.pyRelated Issues/PRs
Additional Context
This affects all users who want to use InMemory or SQLite backends with the
create_memory_item()API, which is the standard flow for creating memories through theMemoryServiceinterface.