Skip to content

JsonPlusRedisSerializer.dumps() fails with TypeError for LangChain message objects #111

@AllieRays

Description

@AllieRays

Problem

The JsonPlusRedisSerializer.dumps() method in langgraph/checkpoint/redis/jsonplus_redis.py has a bug that causes it to fail when serializing LangChain message objects (e.g., HumanMessage, AIMessage, SystemMessage).

Expected Behavior

Successfully returns bytes
b'{"lc":1,"type":"constructor","id":["langchain","schema","messages","HumanMessage"],"kwargs":{...}}'

And round-trip serialization should work:

deserialized = serializer.loads(serialized)
assert isinstance(deserialized, HumanMessage)
assert deserialized.content == "Hello, world!"

Error:

Root Cause

The current implementation attempts to call super().dumps() as a fallback when orjson.dumps(obj) fails.
However, the parent class JsonPlusSerializer does not have a dumps() method, causing an AttributeError. This means the fallback never works, and LangChain objects fail to serialize.

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