[azure-core] _aiohttp_body_helper does not decompress Content-Encoding: br (Brotli)
Maintainer thường phản hồi trong vòng 1 ngày
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 2/5
- Thời gian dự kiến
- 1-3 giờ
- Mức phù hợp với người mới
- 76/100
Hướng nghiên cứu
Bắt đầu tại azure/core/utils/_pipeline_transport_rest_shared.py, ở _aiohttp_body_helper, và so sánh cách xử lý gzip và deflate hiện có với đường dẫn br được báo cáo. Kiểm tra cách tính khả dụng của Brotli được khai báo, sau đó xác minh rằng phản hồi được mã hóa bằng Brotli được giải nén trước khi response.text() chạy và không còn gây ra UnicodeDecodeError.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
Bug Report
Package: azure-core 1.41.0 (also affects azure-ai-agentserver-responses 1.0.0b7)
Description
_aiohttp_body_helper in azure.core.utils._pipeline_transport_rest_shared handles Content-Encoding: gzip and Content-Encoding: deflate, but does not handle Content-Encoding: br (Brotli). When an upstream service returns a Brotli-compressed response, the raw compressed bytes pass through to response.text(), which then raises UnicodeDecodeError.
Reproduction
This surfaces when using azure-ai-agentserver-responses as a Foundry Hosted Agent. The Foundry storage API (/storage/history/item_ids) returns Content-Encoding: br. The FoundryStorageProvider calls http_resp.text() which triggers the decode error.
The FoundryStorageProvider intentionally excludes ContentDecodePolicy from 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:
def _aiohttp_body_helper(response):
...
enc = response.headers.get("Content-Encoding")
if enc in ("gzip", "deflate"): # <- "br" not handled
...
return response._content # raw Brotli bytes pass through
Expected Behavior
Brotli responses should be decompressed transparently, matching how gzip/deflate are handled.
Suggested Fix
if enc in ("gzip", "deflate"):
...
elif enc == "br":
import brotli
response._content = brotli.decompress(response._content)
response._decompressed_content = True
return response._content
(The brotli package is already a common transitive dependency via aiohttp[speedups].)
Workaround
We monkey-patch _aiohttp_body_helper at import time to add Brotli support.
Environment
- Python 3.11
azure-core==1.41.0azure-ai-agentserver-responses==1.0.0b7- Platform: Azure AI Foundry Hosted Agent (Linux container)
- Ngôn ngữ chính
- Python
- Star
- 5.6k
- Fork
- 3.4k
- Merge trung bình
- 2 ngày 1 phút
- Pull request đã merge (30 ngày)
- 218
Chuẩn bị môi trường
Khởi chạy dev container của dự án ngay trên trình duyệt, bằng tài khoản GitHub của bạn.
- Không có Dockerfile hay tệp Docker Compose
- Có mẫu pull request
- Đọc hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của Azure/azure-sdk-for-python
-
Evaluation Service Attention
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 84/100
Azure/azure-sdk-for-python#49190 · 1 bình luận · 1 reaction ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Update CODEOWNERSĐang mở
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 90/100
Azure/azure-sdk-for-python#49183 · 1 reaction ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Evaluation Service Attention
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 75/100
Azure/azure-sdk-for-python#49153 · 1 bình luận · 1 reaction ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Search Service Attention
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 74/100
Azure/azure-sdk-for-python#48555 · 1 bình luận · 1 reaction ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
Azure/azure-sdk-for-python#46697 ·
Maintainer thường phản hồi trong vòng 1 ngày
Tất cả issue của Azure/azure-sdk-for-python
Issue tương tự
-
bug server
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
sportsdataverse/sportsdataverse-py#641 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 82/100
googleapis/google-cloud-python#18532 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
Maintainer thường phản hồi trong vòng 1 ngày