ChannelServiceRoutes route result handling improvements - #452
Closed
Rodrigo Brandão (rodrigobr-msft) wants to merge 17 commits into
Closed
ChannelServiceRoutes route result handling improvements#452Rodrigo Brandão (rodrigobr-msft) wants to merge 17 commits into
Rodrigo Brandão (rodrigobr-msft) wants to merge 17 commits into
Conversation
…ce configuration binding in tests
…ent and SidecarAuth functionality
… update related tests for consistency
…iguration for anonymous access control; add tests for new behaviors
…t/Agents-for-python into users/robrandao/general
Copilot started reviewing on behalf of
Rodrigo Brandão (rodrigobr-msft)
July 8, 2026 20:12
View session
This was
linked to
issues
Jul 8, 2026
Contributor
There was a problem hiding this comment.
Pull request overview
This PR refines the channel service HTTP surface area by tightening typing for model (de)serialization and improving consistency/clarity in route and adapter behavior across the core hosting HTTP stack.
Changes:
- Introduces generic, overloaded model serialization/deserialization helpers in
ChannelServiceRoutesand updates several route handler return types to better reflect JSON payload shapes. - Adjusts DELETE route behavior in
ChannelServiceRoutesto return an empty JSON object ({}) for more consistent JSON responses. - Improves
HttpAdapterBaseinitialization validation and clarifiesHttpResponseFactory.accepted()response metadata.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 4 comments.
| File | Description |
|---|---|
| libraries/microsoft-agents-hosting-core/microsoft_agents/hosting/core/http/_http_response.py | Tweaks the 202 Accepted factory to explicitly set content_type=None. |
| libraries/microsoft-agents-hosting-core/microsoft_agents/hosting/core/http/_http_adapter_base.py | Refactors factory initialization/validation for clearer error handling. |
| libraries/microsoft-agents-hosting-core/microsoft_agents/hosting/core/http/_channel_service_routes.py | Adds typed (de)serialization helpers and updates multiple route handler return types and DELETE responses. |
| libraries/microsoft-agents-hosting-aiohttp/microsoft_agents/hosting/aiohttp/channel_service_route_table.py | Broadens aiohttp json_response typing to support list payloads as well as dict payloads. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Rodrigo Brandão (rodrigobr-msft)
marked this pull request as ready for review
July 9, 2026 18:55
Copilot started reviewing on behalf of
Rodrigo Brandão (rodrigobr-msft)
July 9, 2026 18:56
View session
Comment on lines
+155
to
+161
| else: | ||
| res = re.match(item_service_url, service_url, re.IGNORECASE) | ||
| if res: | ||
| connection_name = item.get("CONNECTION") | ||
| connection = self.get_connection(connection_name) | ||
| if connection: | ||
| return connection |
Comment on lines
+119
to
+122
| if res: | ||
| return self.serialize_model(res) | ||
| else: | ||
| return {} |
Comment on lines
+110
to
112
| async def delete_activity(self, request: HttpRequestProtocol) -> dict: | ||
| """Handle DELETE /v3/conversations/{conversation_id}/activities/{activity_id}.""" | ||
| conversation_id = request.get_path_param("conversation_id") |
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 introduces several type safety improvements, error handling enhancements, and API behavior adjustments across the channel service and HTTP handling modules. The main focus is on making model serialization/deserialization more robust and explicit, improving type annotations for better static analysis, and ensuring more consistent API responses.
Type safety and serialization improvements:
serialize_modelanddeserialize_from_bodymethods inChannelServiceRoutesto use generic type variables and overloads, improving type safety and static analysis for model serialization and deserialization (_channel_service_routes.py). [1] [2] [3] [4]get_activity_members,get_conversation_members,send_conversation_history,upload_attachment) to return more accurate types (list[dict]ordict | list[dict]), reflecting the actual API responses. [1] [2] [3] [4]API consistency and response handling:
delete_activityanddelete_conversation_memberto return empty dictionaries instead ofNone, ensuring consistent JSON responses for DELETE endpoints (_channel_service_routes.py). [1] [2]json_responsefunction in the aiohttp route table to accept bothdictandlist[dict], supporting more flexible response types (channel_service_route_table.py).accepted()static method inHttpResponseto explicitly setcontent_type=None, clarifying the response format for 202 Accepted responses (_http_response.py).Error handling and initialization logic:
HttpAdapterBaseto enforce that either achannel_service_client_factoryor aconnection_managermust be provided, raising a clear error if neither is supplied (_http_adapter_base.py).