Hacktoberfest 2026: le issue che i maintainer hanno segnato per ottobre, aperte e adatte ai principianti. Sfoglia le issue Hacktoberfest

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

Aperta Adatta ai principianti
#47,186 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
2/5
Tempo stimato
1-3 ore
Idoneità per principianti
76/100
Tipo di issue
Bug
Chiarezza
Specificata chiaramente
Stato di attività
Tranquilla
Stack tecnologico
python
Ambito
backend

Direzione di ricerca

Inizia in azure/core/utils/_pipeline_transport_rest_shared.py, in _aiohttp_body_helper, e confronta la gestione esistente di gzip e deflate con il percorso br segnalato. Controlla come viene dichiarata la disponibilità di Brotli, quindi verifica che una risposta codificata con Brotli venga decompressa prima dell'esecuzione di response.text() e non generi più UnicodeDecodeError.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

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)
Lingua principale
Python
Stelle
5.6k
Fork
3.4k
Merge medio
1g 17h
PR unite (30g)
195

Preparare l'ambiente

Apri in Codespaces

Avvia il container di sviluppo del progetto nel browser, con il tuo account GitHub.

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di Azure/azure-sdk-for-python

Tutte le issue di Azure/azure-sdk-for-python

Issue simili

Altre issue su Python

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.