fix: resolve string formatting error in MCP client error handling #1446
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
Fixes a
TypeError: not all arguments converted during string formattingerror that occurs when MCP error messages contain%characters (common in URL-encoded strings from MCP servers like Bedrock AgentCore).Related Issues
Fixes #1244
Root Cause
In
_handle_error_message(), the log call was:The format string had no
%splaceholder, butmessagewas passed as an argument. Whenmessagecontained%characters (e.g.,unknown request id: abc%20123), Python's%formatting in_log_debug_with_threadwould fail.Solution
Add
%sformat specifier to the log message:Documentation PR
No documentation changes required.
Type of Change
Testing
test_handle_error_message_with_percent_in_messagehatch fmt --formatter✅hatch fmt --linter✅Checklist
🦆