-
Notifications
You must be signed in to change notification settings - Fork 3.3k
[azure-core] _aiohttp_body_helper does not decompress Content-Encoding: br (Brotli) #47186
Copy link
Copy link
Open
Labels
customer-reportedIssues that are reported by GitHub users external to the Azure organization.Issues that are reported by GitHub users external to the Azure organization.needs-triageWorkflow: This is a new issue that needs to be triaged to the appropriate team.Workflow: This is a new issue that needs to be triaged to the appropriate team.questionThe issue doesn't require a change to the product in order to be resolved. Most issues start as thatThe issue doesn't require a change to the product in order to be resolved. Most issues start as that
Metadata
Metadata
Assignees
Labels
customer-reportedIssues that are reported by GitHub users external to the Azure organization.Issues that are reported by GitHub users external to the Azure organization.needs-triageWorkflow: This is a new issue that needs to be triaged to the appropriate team.Workflow: This is a new issue that needs to be triaged to the appropriate team.questionThe issue doesn't require a change to the product in order to be resolved. Most issues start as thatThe issue doesn't require a change to the product in order to be resolved. Most issues start as that
Type
Fields
Give feedbackNo fields configured for issues without a type.
Bug Report
Package:
azure-core1.41.0 (also affectsazure-ai-agentserver-responses1.0.0b7)Description
_aiohttp_body_helperinazure.core.utils._pipeline_transport_rest_sharedhandlesContent-Encoding: gzipandContent-Encoding: deflate, but does not handleContent-Encoding: br(Brotli). When an upstream service returns a Brotli-compressed response, the raw compressed bytes pass through toresponse.text(), which then raisesUnicodeDecodeError.Reproduction
This surfaces when using
azure-ai-agentserver-responsesas a Foundry Hosted Agent. The Foundry storage API (/storage/history/item_ids) returnsContent-Encoding: br. TheFoundryStorageProvidercallshttp_resp.text()which triggers the decode error.The
FoundryStorageProviderintentionally excludesContentDecodePolicyfrom its pipeline (with a comment noting gzip crashes), so there is no other layer handling decompression.Root Cause
In
azure/core/utils/_pipeline_transport_rest_shared.py:Expected Behavior
Brotli responses should be decompressed transparently, matching how gzip/deflate are handled.
Suggested Fix
(The
brotlipackage is already a common transitive dependency viaaiohttp[speedups].)Workaround
We monkey-patch
_aiohttp_body_helperat import time to add Brotli support.Environment
azure-core==1.41.0azure-ai-agentserver-responses==1.0.0b7