Home / Function/ test_no_triple_escaping() — langchain Function Reference

test_no_triple_escaping() — langchain Function Reference

Architecture documentation for the test_no_triple_escaping() function in test_secret_injection.py from the langchain codebase.

Entity Profile

Dependency Diagram

graph TD
  3ead3889_ca0f_ef8c_66d6_dd926ffeb1f7["test_no_triple_escaping()"]
  b09351c3_d578_8162_f31e_d033b61eaed5["TestEscapingEfficiency"]
  3ead3889_ca0f_ef8c_66d6_dd926ffeb1f7 -->|defined in| b09351c3_d578_8162_f31e_d033b61eaed5
  style 3ead3889_ca0f_ef8c_66d6_dd926ffeb1f7 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

libs/core/tests/unit_tests/load/test_secret_injection.py lines 320–340

    def test_no_triple_escaping(self) -> None:
        """Verify dumpd doesn't cause triple/multiple escaping."""
        h = HumanMessage(
            "Hello",
            additional_kwargs={"bar": [MALICIOUS_SECRET_DICT]},
        )
        a = AIMessage("foo", additional_kwargs={"bar": [dumpd(h)]})
        d = dumpd(a)

        serialized = json.dumps(d)
        # Count nested escape markers -
        # should be max 2 (one for HumanMessage, one for secret)
        # Not 3+ which would indicate re-escaping of already-escaped content
        escape_count = len(re.findall(r"__lc_escaped__", serialized))

        # The HumanMessage dict gets escaped (1), the secret inside gets escaped (1)
        # Total should be 2, not 4 (which would mean triple nesting)
        assert escape_count <= 2, (
            f"Found {escape_count} escape markers, expected <= 2. "
            f"This indicates unnecessary re-escaping.\n{serialized}"
        )

Domain

Subdomains

Frequently Asked Questions

What does test_no_triple_escaping() do?
test_no_triple_escaping() is a function in the langchain codebase, defined in libs/core/tests/unit_tests/load/test_secret_injection.py.
Where is test_no_triple_escaping() defined?
test_no_triple_escaping() is defined in libs/core/tests/unit_tests/load/test_secret_injection.py at line 320.

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free