Hub requests fail with HF_HUB_DISABLE_TELEMETRY=1 (empty user agent → illegal header)

Chiusa Adatta ai principianti
#926 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

Una pull request collegata è già stata integrata.

  • #939 di @danieldk — integrata

Valutazione

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

Direzione di ricerca

Trova _get_hf_api e segui il modo in cui passa lo user agent a huggingface_hub; l’issue non indica il file né il test, quindi cerca nel repository questa funzione e il test #510 esistente. Riproduci il problema con HF_HUB_DISABLE_TELEMETRY=1 usando il comando nell’issue, poi verifica che la richiesta vada a buon fine con la telemetria disabilitata. Valuta di estendere il test #510 per coprire questo percorso.

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

Descrizione

#510 fixed the trailing "; " in the User-Agent when telemetry is on, but the telemetry-off path still hits it. With HF_HUB_DISABLE_TELEMETRY=1, _get_hf_api() passes user_agent="", huggingface_hub appends "; " + user_agent for any string, and the header ends in "; ":

LocalProtocolError: Illegal header value b'kernels/0.17.2; hf_hub/2.2.0; python/3.13.12; '

The first call to fail is usually the trust check, which surfaces it as a trust problem instead:

ValueError: Kernel repository 'kernels-community/flash-attn2' could not verify publisher trust status. Set trust_remote_code=True ...

So get_kernel (and transformers' flash_attention_2 → kernels-community/flash-attn2 fallback) doesn't work for anyone who turns telemetry off, which is common in CI and containers.

HF_HUB_DISABLE_TELEMETRY=1 python -c "
from kernels import get_kernel
get_kernel('kernels-community/flash-attn2', version=3)"

Reproduces with kernels 0.17.2 and main (3d87832e), huggingface_hub 2.2.0. Without the env var, the same call works.

Passing user_agent=user_agent_str or None in _get_hf_api fixes it. The #510 test could also run with telemetry off. It might also help if the trust check included the underlying error.

Happy to open a PR for this if that works for you.

Lingua principale
Python
Stelle
781
Fork
141
Merge medio
1g 8h
PR unite (30g)
65

Preparare l'ambiente

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 huggingface/kernels

Tutte le issue di huggingface/kernels

Issue simili

Altre issue su Python

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.