chore: Restrict "json" type deserialization#6269
Merged
Merged
Conversation
William FH (hinthornw)
commented
Oct 10, 2025
Contributor
- Rm untyped loads/dumps
- Restrict to an allow list
|
The latest updates on your projects. Learn more about Vercel for GitHub. 1 Skipped Deployment
💡 Enable Vercel Agent with $100 free credit for automated AI reviews |
8108cd7 to
d92ebba
Compare
Sydney Runkle (sydney-runkle)
approved these changes
Oct 17, 2025
Eugene Yurtsev (eyurtsev)
approved these changes
Oct 17, 2025
|
checkpoint\langgraph\checkpoint\memory_init_.py there exists the same problem. Should it be fixed? |
4 tasks
Sydney Runkle (sydney-runkle)
added a commit
that referenced
this pull request
Apr 27, 2026
…ist (#7582) ## Summary Fixes #7498 — `MESSAGE_COERCION_FAILURE` when resuming threads checkpointed before v1.0.1. **Root cause:** PR #6269 (v1.0.1) added an `_allowed_json_modules` security gate to `JsonPlusSerializer._reviver`. The gate defaults to `None`, so old `"json"`-format checkpoint blobs containing `lc=2` constructor dicts (the pre-msgpack serialization format for pydantic objects like `HumanMessage`) are now returned as raw dicts instead of being reconstructed. Those raw dicts reach `add_messages → convert_to_messages`, which sees `type="constructor"` and raises `MESSAGE_COERCION_FAILURE`. Fresh first-turn messages are unaffected because current `dumps_typed` only writes `"msgpack"` blobs. **Fix:** `_reviver` now reconstructs `lc=2` blobs whose target class is already in `SAFE_MSGPACK_TYPES` — the same curated allowlist already used by the msgpack deserialization path (includes all standard LangChain message types). Unknown classes are still blocked, preserving the security intent of #6269. ## Changes - `libs/checkpoint/langgraph/checkpoint/serde/jsonplus.py` — add `_is_safe_json_type()` helper; update `_reviver` and `_check_allowed_json_modules` to allow safe types without an explicit allowlist - `libs/checkpoint/tests/test_jsonplus.py` — two new regression tests: safe-type `lc=2` blobs revive correctly; unknown-type `lc=2` blobs stay blocked ## Test plan - [ ] `test_lc2_json_safe_type_revives_without_allowlist` — `HumanMessage`/`AIMessage` lc=2 JSON blobs round-trip to proper `BaseMessage` objects with no allowlist configured - [ ] `test_lc2_json_unknown_type_stays_blocked_without_allowlist` — `pprint.pprint` lc=2 blob still returns raw dict (not reconstructed) - [ ] `test_deserde_invalid_module` — existing behaviour unchanged - [ ] Full `test_jsonplus.py` suite: 93/93 passing Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
xingshuozhu1998
pushed a commit
to xingshuozhu1998/langgraph
that referenced
this pull request
May 1, 2026
- Rm untyped loads/dumps - Restrict to an allow list --------- Co-authored-by: Sydney Runkle <sydneymarierunkle@gmail.com>
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.