fix: sanitize non-string datetime values in memU database - #41
Merged
Merged
Conversation
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
2025for "tax year 2025") in thehappened_atcolumn ofmemu_memory_itemsdatetime.fromisoformat()crashes on non-string values, which breakslist_items()and prevents the item cache from loading_sanitize_memu_datetimes()that runs at startup before memu-py opens the database, converting integer values to proper datetime stringsRoot cause
3 tax-related items created during a tax filing session had
happened_at = 2025(bare integer). This crashed everylist_items()call, leaving the item cache at size 0 and making all recall return no results.Test plan
test_memu_bridge.pycovering integer fix, valid preservation, and missing DB