Skip to content

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

Closed

Description

@rycerzes

#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 (3d87832), 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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions