fix(core): accept non-dict Mapping values in mustache templates - #39680
Merged
ccurme (ccurme) merged 1 commit intoAug 18, 2026
Merged
Conversation
Lingjin (Haaaarry)
requested a review
from Eugene Yurtsev (eyurtsev)
as a code owner
August 17, 2026 02:31
This comment has been minimized.
This comment has been minimized.
ccurme (ccurme)
approved these changes
Aug 18, 2026
ccurme (ccurme)
merged commit Aug 18, 2026
9c21d84
into
langchain-ai:master
104 of 189 checks passed
Merging this PR will not alter performance
Comparing Footnotes
|
29 tasks
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.
Fixes #39678
Mustache templates document their input as a
Mapping[str, Any], but only plaindictvalues actually resolved. Any otherMapping— aChainMap,UserDict,MappingProxyType, oros.environ— silently rendered as an empty string, so users passing a validMappingsaw variables disappear with no error and no way to tell a missing key from an unsupported type.The nested-value lookup now dispatches on the abstract
MappingABC instead of the concretedict, so everyMappingresolves through__getitem__exactly as the API promises. Theelsebranch that rejects traversal into arbitrary objects is unchanged, so the earlier template-injection hardening still applies.Added a unit test covering
ChainMap,UserDict, andMappingProxyTypevalues.Release note
Mustache prompt templates now resolve variables from any
Mappingvalue (such asChainMap,UserDict, oros.environ), not onlydict.This contribution was prepared with AI assistance.