SqliteSaver.list(filter=...) silently misses nested metadata values containing non-ASCII text
Checked other resources
- This is a bug, not a usage question.
- I added a clear and descriptive title that summarizes this issue.
- I used the GitHub search to find a similar question and didn't find it.
- I am sure that this is a bug in LangGraph rather than my code.
- The bug is not resolved by updating to the latest stable version of LangGraph (or the specific integration package).
- This is not related to the langchain-community package.
- I posted a self-contained, minimal, reproducible example. A maintainer can copy it and run it AS IS.
Related Issues / PRs
None for the checkpoint savers that I could find. #8786, #8759 and #8829 are similar filter divergences, but in SqliteStore / InMemoryStore (a different code path).
Reproduction Steps / Example Code (Python)
import sqlite3
from langgraph.checkpoint.base import empty_checkpoint
from langgraph.checkpoint.memory import InMemorySaver
from langgraph.checkpoint.sqlite import SqliteSaver
config = {"configurable": {"thread_id": "1", "checkpoint_ns": ""}}
cases = {
"nested, ASCII": {"user": {"name": "Jose"}},
"nested, non-ASCII": {"user": {"name": "José"}},
"list, non-ASCII": {"tags": ["café"]},
}
for label, metadata in cases.items():
for saver in (
InMemorySaver(),
SqliteSaver(sqlite3.connect(":memory:", check_same_thread=False)),
):
saver.put(config, empty_checkpoint(), metadata, {})
hits = len(list(saver.list(config, filter=metadata)))
print(f"{label:18} {type(saver).__name__:14} {hits}")
# Output:
# nested, ASCII InMemorySaver 1
# nested, ASCII SqliteSaver 1
# nested, non-ASCII InMemorySaver 1
# nested, non-ASCII SqliteSaver 0
# list, non-ASCII InMemorySaver 1
# list, non-ASCII SqliteSaver 0Error Message and Stack Trace (if applicable)
No error. The filter silently returns no results.Description
Filtering checkpoints on a nested metadata value (dict or list) that contains non-ASCII text returns nothing with SqliteSaver / AsyncSqliteSaver, while InMemorySaver returns the match. Flat string values like {"user": "José"} work fine.
Cause: put stores metadata with json.dumps(..., ensure_ascii=False), but _where_value in langgraph/checkpoint/sqlite/utils.py serializes dict/list filter values with the default ensure_ascii=True. The query compares json_extract(...) to that string as text, so {"name":"José"} is compared to {"name":"José"} and never matches.
Proposed fix (one line in _where_value):
return ("= ?", json.dumps(query_value, separators=(",", ":"), ensure_ascii=False))I tried this locally: the repro above then matches in all cases and the existing checkpoint-sqlite tests pass. Happy to open a PR with a regression test (sync + async) if you'd like — could you assign this to me?
A related case the one-line fix does not cover: because the comparison is textual, a nested dict filter only matches if its keys are in the same order as the stored metadata ({"a": 1, "b": 2} vs {"b": 2, "a": 1} returns 0 on SQLite, 1 on InMemorySaver). PostgresSaver uses JSONB containment (metadata @> %s), so key order doesn't matter there. I left it out of the proposed fix since it probably needs a design call; happy to include it if you want.
System Info
OS: Windows 11 (10.0.26200) Python: 3.13.9 langgraph: 1.2.12 langgraph-checkpoint: 4.2.0 langgraph-checkpoint-sqlite: 3.1.1 langchain_core: 1.6.1 SQLite: 3.50.4 Tested on main @ 7daa3ab49
Source: langchain-ai/langgraph