Skip to content

Commit a4b7da3

Browse files
committed
fix: handle missing blob attribute in shallow checkpoint savers (#80)
Add defensive checks in AsyncShallowRedisSaver and ShallowRedisSaver to filter out documents with None or missing blob attributes when loading pending sends. This prevents AttributeError when querying checkpoint writes from the TASKS channel. Fixes #80
1 parent 13ddc96 commit a4b7da3

File tree

3 files changed

+397
-8
lines changed

3 files changed

+397
-8
lines changed

langgraph/checkpoint/redis/ashallow.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -646,12 +646,11 @@ async def _aload_pending_sends(
646646

647647
# Extract type and blob pairs
648648
# Handle both direct attribute access and JSON path access
649+
# Filter out documents where blob is None (similar to AsyncRedisSaver in aio.py)
649650
return [
650-
(
651-
getattr(doc, "type", ""),
652-
getattr(doc, "$.blob", getattr(doc, "blob", b"")),
653-
)
651+
(getattr(doc, "type", ""), blob)
654652
for doc in sorted_writes
653+
if (blob := getattr(doc, "$.blob", getattr(doc, "blob", None))) is not None
655654
]
656655

657656
async def _aload_pending_writes(

langgraph/checkpoint/redis/shallow.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -675,12 +675,11 @@ def _load_pending_sends(
675675

676676
# Extract type and blob pairs
677677
# Handle both direct attribute access and JSON path access
678+
# Filter out documents where blob is None (similar to RedisSaver in __init__.py)
678679
return [
679-
(
680-
getattr(doc, "type", ""),
681-
getattr(doc, "$.blob", getattr(doc, "blob", b"")),
682-
)
680+
(getattr(doc, "type", ""), blob)
683681
for doc in sorted_writes
682+
if (blob := getattr(doc, "$.blob", getattr(doc, "blob", None))) is not None
684683
]
685684

686685
def _make_shallow_redis_checkpoint_key_cached(

0 commit comments

Comments
 (0)