Skip to content

fix(config): restore huggingface env precedence#3329

Open
gaord wants to merge 2 commits into
Hmbown:mainfrom
gaord:fix/huggingface-provider-registry-drift
Open

fix(config): restore huggingface env precedence#3329
gaord wants to merge 2 commits into
Hmbown:mainfrom
gaord:fix/huggingface-provider-registry-drift

Conversation

@gaord

@gaord gaord commented Jun 19, 2026

Copy link
Copy Markdown
Contributor

This restores the Hugging Face API key env precedence on the TUI config surface so scripts/check-provider-registry.py (the CI/Lint gate) passes again on main.

Background

  • crates/tui/src/config.rs previously expressed the precedence through a helper (provider_env_api_key), but the registry lint script checks for the literal std::env::var("HUGGINGFACE_API_KEY") / std::env::var("HF_TOKEN") strings in this file and fails when it cannot find them in the expected order.
  • That drift is unrelated to the work in feat(tui): preserve thinking/tool blocks when seeding thread from session #3300 (session/thread process preservation), so it is being fixed here on its own branch off the latest main.

What changed

  • provider_env_api_key() now spells out the Hugging Face env order explicitly: HUGGINGFACE_API_KEY first, falling back to HF_TOKEN.
  • Behavior on the runtime side is unchanged: HF_TOKEN alone still works, HUGGINGFACE_API_KEY still wins when both are set, empty values are ignored, and the rest of the providers continue to flow through the existing helper path.
  • The Hugging Face config tests (huggingface_hf_token_env_api_key_resolves, huggingface_short_env_fallbacks_configure_route, huggingface_env_overrides_key_base_url_and_model, huggingface_missing_key_error_mentions_env_fallbacks, etc.) still pass.

Validation

  • python3 scripts/check-provider-registry.py now reports Provider registry drift check passed.
  • cargo test -p codewhale-tui huggingface_ is green (6 passed).

Out of scope

Keep the TUI Hugging Face API key lookup aligned with the shipped provider registry contract by checking HUGGINGFACE_API_KEY before HF_TOKEN explicitly in config.rs.

This makes scripts/check-provider-registry.py pass again on main while preserving the existing runtime fallback behavior and the targeted Hugging Face config tests.
@gaord gaord requested a review from Hmbown as a code owner June 19, 2026 09:16

@greptile-apps greptile-apps Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Your free trial has ended. If you'd like to continue receiving code reviews, you can add a payment method here.

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request refactors the Hugging Face API key environment variable resolution in crates/tui/src/config.rs. It replaces direct checks of HF_TOKEN with a call to provider_env_api_key, which has been updated to explicitly handle the precedence of HUGGINGFACE_API_KEY over HF_TOKEN while ensuring the values are non-empty. Additionally, some import statements have been sorted alphabetically. There are no review comments to address, and I have no further feedback to provide.

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.

CI Lint runs cargo fmt -- --check, and this change removes the remaining formatting drift (import ordering) so the lint job passes.

@greptile-apps greptile-apps Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Your free trial has ended. If you'd like to continue receiving code reviews, you can add a payment method here.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant