[PR #809] [MERGED] Fix bug in add_conditional_edges when no path_map is provided #1696

Closed
opened 2026-02-20 17:45:20 -05:00 by yindo · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/langchain-ai/langgraph/pull/809
Author: @aaw
Created: 6/25/2024
Status: Merged
Merged: 6/26/2024
Merged by: @nfcampos

Base: mainHead: fix-callable-with-no-path-map


📝 Commits (2)

  • eaa20a9 Fix bug in add_conditional_edges when no path_map is provided
  • 6b19f47 More defensive, additional test

📊 Changes

2 files changed (+63 additions, -7 deletions)

View changed files

📝 libs/langgraph/langgraph/graph/graph.py (+12 -7)
📝 libs/langgraph/tests/test_pregel.py (+51 -0)

📄 Description

When an instance of a callable class is passed as the path arg to add_conditional_edges but no path_map is provided, get_type_hints(path) is called, which raises a TypeError (since get_type_hints only accepts a module, class, method, or function).

This patch fixes the error by trying to get type hints from path.__call__ first, which should work for instances of callable classes.

Tested: Added a test that raises TypeError without the fix in this patch but passes with the fix.


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/langchain-ai/langgraph/pull/809 **Author:** [@aaw](https://github.com/aaw) **Created:** 6/25/2024 **Status:** ✅ Merged **Merged:** 6/26/2024 **Merged by:** [@nfcampos](https://github.com/nfcampos) **Base:** `main` ← **Head:** `fix-callable-with-no-path-map` --- ### 📝 Commits (2) - [`eaa20a9`](https://github.com/langchain-ai/langgraph/commit/eaa20a95e9b82282d3a8718a783b9e37224c9e41) Fix bug in add_conditional_edges when no path_map is provided - [`6b19f47`](https://github.com/langchain-ai/langgraph/commit/6b19f472fb5c940c0c1074b2319742a1427c8d89) More defensive, additional test ### 📊 Changes **2 files changed** (+63 additions, -7 deletions) <details> <summary>View changed files</summary> 📝 `libs/langgraph/langgraph/graph/graph.py` (+12 -7) 📝 `libs/langgraph/tests/test_pregel.py` (+51 -0) </details> ### 📄 Description When an instance of a callable class is passed as the path arg to add_conditional_edges but no path_map is provided, get_type_hints(path) is called, which raises a TypeError (since get_type_hints only accepts a module, class, method, or function). This patch fixes the error by trying to get type hints from path.\_\_call\_\_ first, which should work for instances of callable classes. Tested: Added a test that raises TypeError without the fix in this patch but passes with the fix. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
yindo added the pull-request label 2026-02-20 17:45:20 -05:00
yindo closed this issue 2026-02-20 17:45:20 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: langchain-ai/langgraph#1696