Skip to content

fix(langchain-classic): fix Chain.save() regression from dict-to-model_dump migration#35667

Open
Mohammad Mohtashim (keenborder786) wants to merge 1 commit intolangchain-ai:masterfrom
keenborder786:fix/chain_save
Open

fix(langchain-classic): fix Chain.save() regression from dict-to-model_dump migration#35667
Mohammad Mohtashim (keenborder786) wants to merge 1 commit intolangchain-ai:masterfrom
keenborder786:fix/chain_save

Conversation

@keenborder786
Copy link
Contributor

Fixes a regression introduced in #33035 where Chain.save() stopped working for all chain types (including LLMChain).
The root cause is that #33035 updated save() to call self.model_dump() but forgot to rename the dict() method override to model_dump(). So the _type key was never being injected into the serialized output, and save() would always hit the "does not support saving" error path.
Renamed the override from dict to model_dump to fix it. Pydantic v2's dict() already delegates to model_dump() under the hood, so nothing breaks.

Fixes: #35665

@github-actions github-actions bot added fix For PRs that implement a fix langchain-classic `langchain-classic` package issues & PRs external labels Mar 8, 2026
@keenborder786 Mohammad Mohtashim (keenborder786) changed the title fix(langchain_classic): fix Chain.save() regression from dict-to-model_dump migration fix(langchain-classic): fix Chain.save() regression from dict-to-model_dump migration Mar 8, 2026
@github-actions github-actions bot added fix For PRs that implement a fix and removed fix For PRs that implement a fix labels Mar 8, 2026
@org-membership-reviewer org-membership-reviewer bot added the trusted-contributor >= 5 merged PRs in the `langchain-ai/langchain` repo label Mar 9, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

external fix For PRs that implement a fix langchain-classic `langchain-classic` package issues & PRs size: S 50-199 LOC trusted-contributor >= 5 merged PRs in the `langchain-ai/langchain` repo

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Chain.save() broken in 0.3.28: model_dump() doesn't inject _type

2 participants