Resolve the Hugging Face token from HF_TOKEN or a stored login - #87
Open
kobihikri wants to merge 1 commit into
Open
Resolve the Hugging Face token from HF_TOKEN or a stored login#87kobihikri wants to merge 1 commit into
kobihikri wants to merge 1 commit into
Conversation
kobihikri
requested review from
abhidas,
erzel,
rajatsen91,
siriuz42,
tamannarayan and
weihaokong
as code owners
August 9, 2026 17:12
|
Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA). View this failed invocation of the CLA check for more information. For the most up to date status, view the checks section at the bottom of the pull request. |
convert_and_upload.py requires --token whenever --repo_id is given, so today the only way to upload is to put a write-scoped Hugging Face credential into argv. On Linux /proc/<pid>/cmdline is world-readable, so that token is visible to any other user on the machine through `ps` for as long as the conversion and upload run, and it is left behind in shell history afterwards. huggingface_hub already resolves credentials from HF_TOKEN and then from the token saved by `hf auth login`, via the exported get_token(). This falls back to that resolution when --token is not passed, and keeps the flag working exactly as before for anyone who prefers it. The error message now names all three options.
kobihikri
force-pushed
the
fix/hf-token-from-env
branch
from
August 9, 2026 17:14
5f91688 to
662e0ce
Compare
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.
While reading the Hugging Face upload utility I noticed that
--tokenis mandatory whenever--repo_idis set:tabfm/tabfm/src/hugging_face/convert_and_upload.py
Lines 191 to 195 in b15593e
So the only way to run an upload today is to put a write-scoped Hugging Face token into the command line. On Linux
/proc/<pid>/cmdlineis world-readable, which means any other user on the machine can read that token out ofpsfor as long as the run lasts, and it is left behind in shell history. A conversion followed by an upload is not a quick command, so the window is not a small one.huggingface_hubalready handles this. Its exportedget_token()resolvesHF_TOKEN, then the token saved byhf auth login, and in CI an OIDC token via Trusted Publishers. It is present in the pinnedhuggingface-hub==1.21.0.This change falls back to
get_token()only when--tokenis not passed, so anyone already passing the flag sees no change — the flag still wins. The error message now names all three ways to supply a credential, and the flag's help text explains why the environment variable is the better default.What I checked, and what I could not: the file parses, and
get_tokenis exported by huggingface_hub 1.21.0. I could not exercise the upload end to end, because that needs write access togoogle/tabfm-1.0.0-pytorch.If you would rather keep the hard requirement on the flag, I am happy to close this — it is your call.
Disclosure: I used an AI assistant to help find and prepare this change. I have reviewed and verified it myself.