| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
There was a problem hiding this comment.
This PR fixes a Python middleware classification edge case where passing a callable class instance (i.e., an object implementing __call__) could trigger an AttributeError while formatting an error message in _determine_middleware_type(), masking the intended MiddlewareException. The update makes middleware name resolution robust for non-function callables and adds regression tests to ensure clear, informative exceptions are raised.
Changes:
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| python/packages/core/agent_framework/_middleware.py | Safely computes a middleware display name and uses it in all exception messages within _determine_middleware_type(). |
| python/packages/core/tests/core/test_middleware_with_agent.py | Adds regression tests ensuring callable class instances produce MiddlewareException messages containing the class name (no AttributeError). |
Sorry, something went wrong.
Python Test Coverage Report •
Python Unit Test Overview
|
||||||||||||||||||||||||||||||
Sorry, something went wrong.
|
the mistaken signature are caught by type checkers (which is good), so we need to explicitly ignore those, see the failing check. Henry Su (@hsusul) |
Sorry, something went wrong.
|
Thanks for pointing that out! Updated the test suite in commit 2d716dce8 to annotate the test middleware lists as list[Any] and set _middleware_type directly on the test class. |
Sorry, something went wrong.
| Back | FazBrowse Home | New Git URL |
Motivation & Context
Passing a callable class instance (a class implementing __call__ with fewer than 2 parameters or an unresolvable middleware type) as middleware caused _determine_middleware_type() to raise an unhandled AttributeError: 'BadMiddleware' object has no attribute '__name__' during exception string formatting, masking the intended MiddlewareException.
Description & Review Guide
What are the major changes?
What is the impact of these changes?
What do you want reviewers to focus on?
Related Issue
Fixes #6697
Contribution Checklist