Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix: Closure Issue in ToolFactory.from_openapi_schema #238

Merged
merged 1 commit into from
Feb 25, 2025

Conversation

bonk1t
Copy link
Collaborator

@bonk1t bonk1t commented Feb 24, 2025

Summary

Fixes Python closure issue in callback creation loop for multiple endpoints in OpenAPI schemas.

Issue

In ToolFactory.py, all callbacks created in the from_openapi_schema method capture the same reference to the path variable. By execution time, all callbacks reference the last path in the loop, causing all API calls to be routed to the last endpoint regardless of intended destination.

Fix

  • Added factory function _create_callback_for_path to create isolated closures
  • Each callback now receives a unique copy of path and method values
  • No API changes or breaking modifications

Testing

Verified with a multi-endpoint schema that each endpoint correctly routes to the appropriate path.

Related Issues

Resolves cases where API calls are incorrectly routed to the wrong endpoint when multiple endpoints exist in the schema.

@VRSEN VRSEN merged commit 349e7b2 into VRSEN:main Feb 25, 2025
1 check failed
@bonk1t bonk1t deleted the fix/tool-factory branch February 25, 2025 15:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants