fix: avoid custom provider shadowing built-in providers
Follow up on salvaged PR #1012. Prevents raw custom-provider names from intercepting built-in provider ids, and keeps the regression coverage focused on current-main behavior.
This commit is contained in:
parent
4422637e7a
commit
88951215d3
2 changed files with 37 additions and 13 deletions
|
|
@ -5,6 +5,7 @@ from __future__ import annotations
|
|||
import os
|
||||
from typing import Any, Dict, Optional
|
||||
|
||||
from hermes_cli import auth as auth_mod
|
||||
from hermes_cli.auth import (
|
||||
AuthError,
|
||||
PROVIDER_REGISTRY,
|
||||
|
|
@ -56,6 +57,19 @@ def _get_named_custom_provider(requested_provider: str) -> Optional[Dict[str, An
|
|||
if not requested_norm or requested_norm == "custom":
|
||||
return None
|
||||
|
||||
# Raw names should only map to custom providers when they are not already
|
||||
# valid built-in providers or aliases. Explicit menu keys like
|
||||
# ``custom:local`` always target the saved custom provider.
|
||||
if requested_norm == "auto":
|
||||
return None
|
||||
if not requested_norm.startswith("custom:"):
|
||||
try:
|
||||
auth_mod.resolve_provider(requested_norm)
|
||||
except AuthError:
|
||||
pass
|
||||
else:
|
||||
return None
|
||||
|
||||
config = load_config()
|
||||
custom_providers = config.get("custom_providers")
|
||||
if not isinstance(custom_providers, list):
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue