Repository navigation
Studio: validate Hugging Face tokens before use - #7261
Conversation
There was a problem hiding this comment.
Code Review
This pull request introduces a cached, rate-limited Hugging Face token validation mechanism. It adds a backend validation endpoint, frontend integration (including a warning dialog and settings controls), and pre-flight validation checks before starting training, loading models, or exporting checkpoints. The review feedback highlights two critical issues: a potential deadlock/indefinite blocking in the backend's single-flight logic if an exception occurs, and a missing exception handler in the frontend's token preparation logic that could crash main workflows on network failures.
Important
The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 9e2dfd7c25
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
|
Ran a focused check here: https://github.com/Imagineer99/unsloth/actions/runs/29746258502 |
|
The frontend lint error should be fine now @Imagineer99. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 28253bd431
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
| model_path: payload.model_path, | ||
| native_path_lease: payload.nativePathLease ?? null, | ||
| hf_token: payload.hf_token, | ||
| hf_token: preparedToken.token, |
There was a problem hiding this comment.
Propagate anonymous token choice to follow-up scans
When an invalid saved token is rejected and the user chooses “Continue without token,” this prepared token is only used for /api/inference/validate; I checked the chat load flows in use-chat-model-runtime.ts and shared-composer.tsx, and they immediately call confirmRemoteCodeIfNeeded with their pre-validation hfToken snapshot. For a public custom-code model with medium/high scan findings, that scan runs with the token Hugging Face already rejected, falls back to an empty consent without a fingerprint, and the subsequent /load uses the anonymous choice and gets blocked because no approved fingerprint was supplied. Return the prepared token from validation or update the chat callers before running the remote-code scan.
Useful? React with 👍 / 👎.
Closes #7253
Studio kept using a saved Hugging Face token even after it expired. This blocked already downloaded models, while the resulting inference error looked like an invalid model. Settings also had no direct way to clear the token.
Fix
Validate non-empty tokens through an authenticated backend endpoint using Hugging Face
whoami. Definitive 401 responses open a shared warning before inference, training, or export, with options to replace the token, continue without it, or cancel.Validation results are cached by token fingerprint. Uncached checks are limited to three per Studio user and client address per hour. Rate limits, network failures, and Hugging Face 5xx responses do not mark a token invalid.
Settings now has an explicit Clear button, keeps the masked field editable, and shows validation status. Inference preflight also reports Hugging Face authentication failures instead of a generic invalid-model error.
Behavior boundaries
Verification
pytest -q studio/backend/tests/test_hf_token_validation.py studio/backend/tests/test_utils.py -qruff checkon the changed backend modules and testsnpm run typecheckhf-authfeature