Python: fix: prevent inner_exception from being lost in AgentFrameworkException#5167
Python: fix: prevent inner_exception from being lost in AgentFrameworkException#5167Bahtya wants to merge 2 commits intomicrosoft:mainfrom
Conversation
The __init__ method unconditionally called super().__init__() after the conditional call with inner_exception, effectively overwriting the exception args and losing the inner_exception reference. Add else branch so super().__init__() is only called once with the correct arguments. Fixes microsoft#5155 Signed-off-by: bahtya <bahtyar153@qq.com>
|
Hi team, just wanted to follow up on this PR. It has been approved by @eavanvalkenburg. There appear to be some CI failures — happy to investigate if they're related to this change. Would appreciate any feedback! |
…handling - test_exception_with_inner_exception: verifies args include inner exception - test_exception_without_inner_exception: verifies args only contain message - test_exception_inner_exception_none_explicit: verifies explicit None Covers both branches of the if/else in __init__.
CI Failure AnalysisThe Python 3.11 test failures are not caused by this PR. They are pre-existing issues in the This error occurs in I have added explicit unit tests for the The coverage and merge-gatekeeper failures are downstream of the Python 3.11 test failure. |
|
@Bahtya please read the following Contributor License Agreement(CLA). If you agree with the CLA, please reply with the following information.
Contributor License AgreementContribution License AgreementThis Contribution License Agreement (“Agreement”) is agreed to by the party signing below (“You”),
|
Problem
AgentFrameworkException.__init__()unconditionally callssuper().__init__(message, *args)after the conditionalsuper().__init__(message, inner_exception, *args). Wheninner_exceptionis provided, the second call overwrites the exception args, losing the inner exception reference.Root Cause
Missing
elsebranch — bothsuper().__init__()calls execute wheninner_exceptionis truthy.Fix
Add
else:branch sosuper().__init__()is called exactly once with the correct arguments.Before:
After:
Fixes #5155