Home / Function/ test_dereference_refs_complex_pattern() — langchain Function Reference

test_dereference_refs_complex_pattern() — langchain Function Reference

Architecture documentation for the test_dereference_refs_complex_pattern() function in test_json_schema.py from the langchain codebase.

Entity Profile

Dependency Diagram

graph TD
  714a0930_3332_4576_dbd6_362e865322ae["test_dereference_refs_complex_pattern()"]
  5d9c8eae_7a4a_0ffa_fa7c_a89825bcf1fa["test_json_schema.py"]
  714a0930_3332_4576_dbd6_362e865322ae -->|defined in| 5d9c8eae_7a4a_0ffa_fa7c_a89825bcf1fa
  style 714a0930_3332_4576_dbd6_362e865322ae fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

libs/core/tests/unit_tests/utils/test_json_schema.py lines 565–634

def test_dereference_refs_complex_pattern() -> None:
    """Test pattern that caused infinite recursion in MCP server schemas."""
    schema = {
        "type": "object",
        "properties": {
            "query": {"$ref": "#/$defs/Query", "additionalProperties": False}
        },
        "$defs": {
            "Query": {
                "type": "object",
                "properties": {"user": {"$ref": "#/$defs/User"}},
            },
            "User": {
                "type": "object",
                "properties": {
                    "id": {"type": "string"},
                    "profile": {"$ref": "#/$defs/UserProfile", "nullable": True},
                },
            },
            "UserProfile": {
                "type": "object",
                "properties": {"bio": {"type": "string"}},
            },
        },
    }

    # This should not cause infinite recursion
    actual = dereference_refs(schema)

    expected = {
        "$defs": {
            "Query": {
                "properties": {"user": {"$ref": "#/$defs/User"}},
                "type": "object",
            },
            "User": {
                "properties": {
                    "id": {"type": "string"},
                    "profile": {"$ref": "#/$defs/UserProfile", "nullable": True},
                },
                "type": "object",
            },
            "UserProfile": {
                "properties": {"bio": {"type": "string"}},
                "type": "object",
            },
        },
        "properties": {
            "query": {
                "additionalProperties": False,
                "properties": {
                    "user": {
                        "properties": {
                            "id": {"type": "string"},
                            "profile": {
                                "nullable": True,
                                "properties": {"bio": {"type": "string"}},
                                "type": "object",
                            },
                        },
                        "type": "object",
                    }
                },
                "type": "object",
            }
        },
        "type": "object",
    }

    assert actual == expected

Domain

Subdomains

Frequently Asked Questions

What does test_dereference_refs_complex_pattern() do?
test_dereference_refs_complex_pattern() is a function in the langchain codebase, defined in libs/core/tests/unit_tests/utils/test_json_schema.py.
Where is test_dereference_refs_complex_pattern() defined?
test_dereference_refs_complex_pattern() is defined in libs/core/tests/unit_tests/utils/test_json_schema.py at line 565.

Analyze Your Own Codebase

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

Try Supermodel Free