Skip to content

fix: sanitize non-string datetime values in memU database - #41

Merged
pufit merged 2 commits into
mainfrom
pufit/fix-memu-datetime-crash
Apr 9, 2026
Merged

pufit merged 2 commits into
mainfrom
pufit/fix-memu-datetime-crash

Conversation

@pufit

@pufit pufit commented Apr 9, 2026

Copy link
Copy Markdown
Member

Summary

  • The LLM date resolver can produce bare integers (e.g. 2025 for "tax year 2025") in the happened_at column of memu_memory_items
  • datetime.fromisoformat() crashes on non-string values, which breaks list_items() and prevents the item cache from loading
  • This silently kills all memory recall — the exception is caught and empty results are returned
  • Adds _sanitize_memu_datetimes() that runs at startup before memu-py opens the database, converting integer values to proper datetime strings

Root cause

3 tax-related items created during a tax filing session had happened_at = 2025 (bare integer). This crashed every list_items() call, leaving the item cache at size 0 and making all recall return no results.

Test plan

  • 3 new tests in test_memu_bridge.py covering integer fix, valid preservation, and missing DB
  • Full suite: 335 passed

Generated by Nerve

pufit added 2 commits April 9, 2026 04:03
The LLM date resolver can produce bare integers (e.g. 2025 for "tax year
2025") in the happened_at column. datetime.fromisoformat() crashes on
non-string values, which breaks list_items() and prevents the item cache
from loading — effectively killing all memory recall silently.

Add _sanitize_memu_datetimes() that runs on startup before memu-py opens
the database, converting integer values to proper datetime strings and
nulling out any other non-text values.
The LLM date resolver can return bare integers (e.g. 2025 for "tax year
2025") instead of ISO date strings. datetime.fromisoformat() crashes on
non-string values, breaking list_items() and the item cache — silently
killing all memory recall.

Two-layer fix:
- _validate_date_value(): validates LLM output at write time, coercing
  bare year integers to "YYYY-01-01" and rejecting garbage values
- _sanitize_memu_datetimes(): startup safety net that fixes any existing
  bad values before memu-py opens the database
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant