Improved validation of response data in select ConversationsOperations methods#317
Open
rodrigobr-msft wants to merge 4 commits intomainfrom
Open
Improved validation of response data in select ConversationsOperations methods#317rodrigobr-msft wants to merge 4 commits intomainfrom
rodrigobr-msft wants to merge 4 commits intomainfrom
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR hardens ConversationsOperations response handling by switching reply_to_activity and send_to_conversation to parse ResourceResponse via UTF-8 decoded bodies and model_validate_json, with tests added to validate behavior for responses with and without content.
Changes:
- Updated
reply_to_activityandsend_to_conversationto decode response bodies and validate viaResourceResponse.model_validate_json, returning an emptyResourceResponsewhen no content is present. - Added new async unit tests for successful responses with JSON content and empty responses for both methods.
Reviewed changes
Copilot reviewed 2 out of 3 changed files in this pull request and generated 9 comments.
| File | Description |
|---|---|
| libraries/microsoft-agents-hosting-core/microsoft_agents/hosting/core/connector/client/connector_client.py | Updates response parsing/validation logic for reply_to_activity and send_to_conversation. |
| tests/hosting_core/connector/test_connector_client.py | Adds unit tests for content vs no-content responses for both methods. |
| tests/hosting_core/connector/init.py | Package init file (no functional logic shown). |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
...osoft-agents-hosting-core/microsoft_agents/hosting/core/connector/client/connector_client.py
Outdated
Show resolved
Hide resolved
...osoft-agents-hosting-core/microsoft_agents/hosting/core/connector/client/connector_client.py
Outdated
Show resolved
Hide resolved
...osoft-agents-hosting-core/microsoft_agents/hosting/core/connector/client/connector_client.py
Outdated
Show resolved
Hide resolved
...osoft-agents-hosting-core/microsoft_agents/hosting/core/connector/client/connector_client.py
Outdated
Show resolved
Hide resolved
Contributor
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 2 out of 3 changed files in this pull request and generated 3 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
...osoft-agents-hosting-core/microsoft_agents/hosting/core/connector/client/connector_client.py
Show resolved
Hide resolved
...osoft-agents-hosting-core/microsoft_agents/hosting/core/connector/client/connector_client.py
Show resolved
Hide resolved
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
This pull request improves the handling of responses in the
ConversationsOperationsmethods and adds comprehensive unit tests to ensure correct behavior. The main focus is on making response parsing more robust and ensuring that both successful and empty responses are handled gracefully.Response handling improvements:
reply_to_activityandsend_to_conversationmethods inconnector_client.pyto decode response bodies as UTF-8 strings and useResourceResponse.model_validate_jsonfor parsing, returning an emptyResourceResponsewhen no content is present. [1] [2] [3]Testing enhancements:
test_connector_client.pycovering both successful responses with content and cases with no content forsend_to_conversationandreply_to_activity, verifying correct parsing and fallback behavior.