fix(models): external_process catalog fetch degrades to fallback_models on error; test mirrors registry via public types

A raising fetch_models() on the external_process branch escaped to
provider_model_ids() outer try and lost the profile fallback_models, unlike the
api_key branch. The admission test mirrored through auth._register_plugin_provider,
which #116553 renames; build the ProviderConfig from public types instead.
This commit is contained in:
teknium1
2026-09-19 19:37:45 -07:00
committed by Teknium
parent 787ad02ec8
commit 22beb95427
2 changed files with 12 additions and 3 deletions

View File

@@ -1511,7 +1511,11 @@ def _profile_live_catalog(normalized: str) -> Optional[list[str]]:
# Every non-api-key profile falls back to its own fallback_models (OAuth plugins have no
# static _PROVIDER_MODELS row), exactly as api_key plugins do below.
if profile.auth_type == "external_process":
live = profile.fetch_models()
try:
live = profile.fetch_models()
except Exception as exc: # a failed subprocess launch degrades to the curated list, like api_key below
logger.debug("external_process catalog fetch failed for %s: %s", normalized, exc)
live = None
return list(live) if live else (list(profile.fallback_models) or None)
if not (profile.auth_type == "api_key" and profile.base_url):
return list(profile.fallback_models) or None

View File

@@ -19,8 +19,13 @@ def _register(monkeypatch, profile):
monkeypatch.setitem(providers._REGISTRY, profile.name, profile)
monkeypatch.delitem(auth.PROVIDER_REGISTRY, profile.name, raising=False)
auth._register_plugin_provider(profile) # what plugin discovery does at import time
monkeypatch.setitem(auth.PROVIDER_REGISTRY, profile.name, auth.PROVIDER_REGISTRY[profile.name])
# Mirror into the auth registry the way plugin discovery does; built from public types so the
# helper is independent of the auth module's private mirroring function.
pconfig = auth.ProviderConfig(
profile.name, profile.display_name or profile.name, profile.auth_type, inference_base_url=profile.base_url)
if profile.auth_type == "api_key" and profile.env_vars:
pconfig = auth._api_key_provider(profile.name, profile.display_name or profile.name, profile.base_url, tuple(profile.env_vars), "")
monkeypatch.setitem(auth.PROVIDER_REGISTRY, profile.name, pconfig)
@pytest.mark.parametrize("auth_type", ["external_process", "oauth_external", "oauth_device_code", "api_key"])