Small tweaks to HTTP-related adapter code - #514
Conversation
There was a problem hiding this comment.
Pull request overview
This PR makes small adjustments to the hosting SDK’s HTTP abstractions and adapter integration points, aiming to improve cross-framework compatibility and tighten type usage.
Changes:
- Makes
HttpResponse.content_typenon-optional and updates the aiohttp adapter to always pass a default content type. - Broadens
HttpRequestProtocol.headersfromdicttoMappingto better match framework header types. - Adjusts the
microsoft_agents.hosting.corepublic exports to expose_Routeinstead of the previously exported (but undefined)Route.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| libraries/microsoft-agents-hosting-core/microsoft_agents/hosting/core/http/_http_response.py | Tightens HttpResponse.content_type typing, impacting response factory behavior. |
| libraries/microsoft-agents-hosting-core/microsoft_agents/hosting/core/http/_http_request_protocol.py | Updates request header typing to Mapping for framework compatibility. |
| libraries/microsoft-agents-hosting-core/microsoft_agents/hosting/core/init.py | Changes the package export surface around route types. |
| libraries/microsoft-agents-hosting-aiohttp/microsoft_agents/hosting/aiohttp/cloud_adapter.py | Ensures aiohttp responses always receive a non-empty content_type. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 4 out of 4 changed files in this pull request and generated no new comments.
Suppressed comments (2)
libraries/microsoft-agents-hosting-core/microsoft_agents/hosting/core/init.py:137
- Exporting "_Route" from the top-level hosting.core package exposes an internal (underscore-prefixed) class in the public interface. If the intent is to provide a public route type, add a public alias (Route = _Route) and export "Route" instead, which also keeps star-imports working without leaking the private name.
"ApplicationOptions",
"InputFile",
"InputFileDownloader",
"Query",
"_Route",
"RouteHandler",
libraries/microsoft-agents-hosting-aiohttp/microsoft_agents/hosting/aiohttp/cloud_adapter.py:72
- Passing content_type through to aiohttp.web.Response unconditionally can crash when HttpResponseFactory.accepted() sets content_type=None (aiohttp expects a str for content_type). Only include content_type when it is not None, so 202 Accepted (and other no-body responses) can omit the header safely.
return Response(
status=http_response.status_code,
headers=http_response.headers,
content_type=http_response.content_type,
)
686fb90
into
main
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 4 out of 4 changed files in this pull request and generated no new comments.
Suppressed comments (2)
libraries/microsoft-agents-hosting-core/microsoft_agents/hosting/core/init.py:136
- core.init now exports the private routing type name ("_Route") in all, but there is still no public Route symbol to import. If Route is intended to be part of the public surface, add a Route alias for _Route and export both names (or at least Route) so users don’t have to depend on a private underscore-prefixed type.
"ApplicationOptions",
"InputFile",
"InputFileDownloader",
"Query",
"_Route",
libraries/microsoft-agents-hosting-aiohttp/microsoft_agents/hosting/aiohttp/cloud_adapter.py:72
- _to_aiohttp_response now always forwards http_response.content_type into aiohttp.web.Response() for empty-body responses, but HttpResponseFactory.accepted() sets content_type=None. Passing None through as content_type can lead to invalid/ambiguous response construction; only include the content_type kwarg when it’s a non-None string.
return Response(
status=http_response.status_code,
headers=http_response.headers,
content_type=http_response.content_type,
)
No description provided.