Skip to content

Bug: InMemory/SQLite backends fail with missing resource_id #318

@lucyfer81

Description

@lucyfer81

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

  1. 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
  2. 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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions