langchain
c6879657 - fix(core): resolve infinite recursion in `_dereference_refs_helper` with mixed `$ref` objects (#32578)

Commit
247 days ago
fix(core): resolve infinite recursion in `_dereference_refs_helper` with mixed `$ref` objects (#32578) **Description:** Fixes infinite recursion issue in JSON schema dereferencing when objects contain both $ref and other properties (e.g., nullable, description, additionalProperties). This was causing Apollo MCP server schemas to hang indefinitely during tool binding. **Problem:** - Commit fb5da8384 changed the condition from `set(obj.keys()) == {"$ref"}` to `"$ref" in set(obj.keys())` - This caused objects with $ref + other properties to be treated as pure $ref nodes - Result: other properties were lost and infinite recursion occurred with complex schemas **Solution:** - Restore pure $ref detection for objects with only $ref key - Add proper handling for mixed $ref objects that preserves all properties - Merge resolved reference content with other properties - Maintain cycle detection to prevent infinite recursion **Impact:** - Fixes Apollo MCP server schema integration - Resolves tool binding infinite recursion with complex GraphQL schemas - Preserves backward compatibility with existing functionality - No performance impact - actually improves handling of complex schemas **Issue:** Fixes #32511 **Dependencies:** None **Testing:** - Added comprehensive unit tests covering mixed $ref scenarios - All existing tests pass (1326 passed, 0 failed) - Tested with realistic Apollo GraphQL schemas - Stress tested with 100 iterations of complex schemas **Verification:** - ✅ `make format` - All files properly formatted - ✅ `make lint` - All linting checks pass - ✅ `make test` - All 1326 unit tests pass - ✅ No breaking changes - full backwards compatibility maintained --------- Co-authored-by: Marcus <marcus@Marcus-M4-MAX.local> Co-authored-by: Eugene Yurtsev <eyurtsev@gmail.com>
Author
Parents
Loading