Hacktoberfest 2026:メンテナが10月に向けて印を付けた、オープンで初心者向けの issue。 Hacktoberfest の issue を見る

[azure-core] _aiohttp_body_helper does not decompress Content-Encoding: br (Brotli)

オープン 初心者向け
#47,186 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

メンテナーはふだん 1 日以内に返信

まだ誰も着手していません。

評価

難易度
2/5
見積もり時間
1〜3時間
初心者へのやさしさ
76/100
issue の種類
バグ
明瞭さ
明確に書かれている
活発さ
静か
技術スタック
python
領域
backend

調査の方向性

azure/core/utils/_pipeline_transport_rest_shared.py の _aiohttp_body_helper から始め、既存の gzip と deflate の処理を報告されている br パスと比較してください。Brotli の利用可能性がどのように宣言されているかを確認し、Brotli でエンコードされたレスポンスが response.text() の実行前に展開され、UnicodeDecodeError を発生させなくなっていることを検証してください。

索引モデルが issue の本文から書いたものです。

説明

Azure.Core customer-reported feature-request needs-team-attention
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.0
  • azure-ai-agentserver-responses==1.0.0b7
  • Platform: Azure AI Foundry Hosted Agent (Linux container)
主要言語
Python
スター
5.6k
フォーク
3.4k
平均マージ
1日 17時間
マージ済み PR(30日)
195

環境構築

Codespaces で開く

このプロジェクトの開発コンテナを、あなたの GitHub アカウントでブラウザ上に起動します。

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

Azure/azure-sdk-for-python のほかの issue

Azure/azure-sdk-for-python の issue をすべて見る

似ている issue

Python の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。