Send HF_TOKEN so gated dataset downloads authenticate - #1817
Merged
Conversation
Every dataset-backed job on main and on PRs has failed with 401 since 31 July 2026. The cause is not the HUGGING_FACE_TOKEN secret: no token is being sent at all. policyengine-core's download_huggingface_dataset passes a token to hf_hub_download only when the repo reports private=True (tools/hugging_face.py:81-90). policyengine-uk-data-private has been public + gated (manual approval) since 31 July, so private is False, core passes token=None, the download goes out anonymously and the gate returns 401 GatedRepoError. Replacing the secret on 10 August could not have fixed this, and the out-of-band validation of that token passed because it supplied the token explicitly - the step core skips. huggingface_hub falls back to the HF_TOKEN environment variable when the explicit token is None (get_token_to_send -> get_token), so exporting the same secret under that name restores authentication. Verified green on #1815, where the gated dataset downloads and the microsimulation suite passes (177 passed, 1 skipped). This is a workaround. The durable fix belongs in policyengine-core, which should pass the token whenever one is available, or test gated alongside private. Refs #1816. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes the CI breakage tracked in #1816. Every dataset-backed job on
mainand on PRs has failed with 401 since 31 July 2026.The cause is not the secret — no token is being sent at all
policyengine-core'sdownload_huggingface_datasetpasses a token tohf_hub_downloadonly when the repo reportsprivate=True(tools/hugging_face.py:81-90):policyengine-uk-data-privatehas been public + gated (manual approval) since 31 July, confirmed against the live Hub:So
privateisFalse, core passestoken=None, the download goes out anonymously, and the gate returns401 GatedRepoError.privateis simply the wrong predicate once a repo is gated rather than private.This explains what looked contradictory in #1816: replacing the
HUGGING_FACE_TOKENsecret on 10 August changed nothing because the credential was never the variable, and the out-of-band validation of that token legitimately passed because it supplied the token explicitly — precisely the step core skips.The fix
huggingface_hubfalls back to theHF_TOKENenvironment variable when the explicit token isNone(get_token_to_send→get_token), so exporting the same secret under that name restores authentication. Two lines per workflow, no new secret.Verification
Applied to #1815, where the previously-401ing gated dataset now downloads and the full suite passes:
Split out of #1815 so it can land on
mainindependently — every dataset-backed PR in the repo stays red until it does.Follow-up
This is a workaround. The durable fix belongs in
policyengine-core: pass the token whenever one is available, or testgatedalongsideprivate. Any country package downloading from a gated HF repo has the same latent bug. Filed as PolicyEngine/policyengine-core#529.No
changelog.dfragment: CI-only change with no user-facing model behaviour, and adding one would trigger a package release.🤖 Generated with Claude Code