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