test_constructor_in_metadata_not_instantiated() — langchain Function Reference
Architecture documentation for the test_constructor_in_metadata_not_instantiated() function in test_secret_injection.py from the langchain codebase.
Entity Profile
Dependency Diagram
graph TD d855292d_d806_7cc7_e39c_f96f654bc392["test_constructor_in_metadata_not_instantiated()"] e14ee3ac_0a78_7aaa_7494_89e3eb699010["TestConstructorInjection"] d855292d_d806_7cc7_e39c_f96f654bc392 -->|defined in| e14ee3ac_0a78_7aaa_7494_89e3eb699010 style d855292d_d806_7cc7_e39c_f96f654bc392 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
libs/core/tests/unit_tests/load/test_secret_injection.py lines 369–392
def test_constructor_in_metadata_not_instantiated(self) -> None:
"""Verify constructor-like dict in metadata is not instantiated."""
malicious_constructor = {
"lc": 1,
"type": "constructor",
"id": ["langchain_core", "messages", "ai", "AIMessage"],
"kwargs": {"content": "injected"},
}
doc = Document(
page_content="Hello",
metadata={"data": malicious_constructor},
)
serialized = dumpd(doc)
deserialized = load(
serialized,
secrets_from_env=True,
allowed_objects=[Document, AIMessage],
)
# The constructor-like dict should be a plain dict, NOT an AIMessage
assert isinstance(deserialized.metadata["data"], dict)
assert deserialized.metadata["data"] == malicious_constructor
Domain
Subdomains
Source
Frequently Asked Questions
What does test_constructor_in_metadata_not_instantiated() do?
test_constructor_in_metadata_not_instantiated() is a function in the langchain codebase, defined in libs/core/tests/unit_tests/load/test_secret_injection.py.
Where is test_constructor_in_metadata_not_instantiated() defined?
test_constructor_in_metadata_not_instantiated() is defined in libs/core/tests/unit_tests/load/test_secret_injection.py at line 369.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free