fix(auth): detect configured providers absent from registry (#66017)

* fix: detect env-var-configured providers absent from PROVIDER_REGISTRY

is_provider_explicitly_configured() only checked PROVIDER_REGISTRY (a
manually-maintained dict) for env-var names. Providers that exist solely
in the models.dev catalog — e.g. openrouter — were never recognised as
explicitly configured, so they were filtered out of the desktop model
picker even when their API key was set in .env.

Add a fallback to get_provider() (which reads the models.dev catalog)
when PROVIDER_REGISTRY returns None. Both ProviderConfig and ProviderDef
expose .auth_type and .api_key_env_vars with the same shape.

* test: keep OpenRouter provider gate assertion behavioral

* chore(release): map salvaged OpenRouter contributor

---------

Co-authored-by: zzpigpinggai <zzpigpinggai@users.noreply.github.com>
This commit is contained in:
Gille 2026-07-16 20:56:45 -06:00 committed by GitHub
parent 629aeeebea
commit 7cb2d2cd4a
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 26 additions and 0 deletions

View file

@ -1605,6 +1605,12 @@ def is_provider_explicitly_configured(provider_id: str) -> bool:
# not by the user explicitly configuring anthropic in Hermes.
_IMPLICIT_ENV_VARS = {"CLAUDE_CODE_OAUTH_TOKEN"}
pconfig = PROVIDER_REGISTRY.get(normalized)
# Fallback to ProviderDef from models.dev catalog when the provider
# isn't in the manually-maintained PROVIDER_REGISTRY (e.g. openrouter).
# Both expose .auth_type and .api_key_env_vars with the same shape.
if pconfig is None:
from hermes_cli.providers import get_provider
pconfig = get_provider(normalized)
if pconfig and pconfig.auth_type == "api_key":
for env_var in pconfig.api_key_env_vars:
if env_var in _IMPLICIT_ENV_VARS:

View file

@ -45,6 +45,7 @@ ACP_REGISTRY_MANIFEST = REPO_ROOT / "acp_registry" / "agent.json"
# Auto-extracted from noreply emails + manual overrides
AUTHOR_MAP = {
"zzpigpinggai@users.noreply.github.com": "zzpigpinggai", # PR #66017 salvage of #63617 (OpenRouter explicit-provider picker visibility)
"sam7894604@gmail.com": "sam7894604", # PR #55803 salvage (discord: /reasoning slash choices)
"bryan@users.noreply.github.com": "hydraxman", # PR #62028 salvage (copilot xhigh) — regression-test commit authored under a bare-noreply local git identity; PR author is @hydraxman
"antydizajn@gmail.com": "antydizajn", # PR #36043 salvage (auxiliary: route custom:<name> through named-provider arm + Palantir Bearer auth)

View file

@ -171,3 +171,22 @@ def test_env_pool_entry_counts_when_var_still_resolves(tmp_path, monkeypatch):
from hermes_cli.auth import is_provider_explicitly_configured
assert is_provider_explicitly_configured("deepseek") is True
def test_provider_not_in_registry_but_in_models_dev(tmp_path, monkeypatch):
"""Providers absent from PROVIDER_REGISTRY but present in the models.dev
catalog (e.g. openrouter) must still be detected via their env vars.
Regression: is_provider_explicitly_configured() only checked
PROVIDER_REGISTRY for env-var names, so providers that exist solely in
the models.dev catalog were never recognised as explicitly configured -
hiding them from the desktop model picker even when their API key was
set in .env.
"""
monkeypatch.setenv("HERMES_HOME", str(tmp_path / "hermes"))
monkeypatch.setenv("OPENROUTER_API_KEY", "sk-or-test-key-12345678")
monkeypatch.delenv("CLAUDE_CODE_OAUTH_TOKEN", raising=False)
(tmp_path / "hermes").mkdir(parents=True, exist_ok=True)
from hermes_cli.auth import is_provider_explicitly_configured
assert is_provider_explicitly_configured("openrouter") is True