Skip to content

fix(providers): warn on duplicate name/alias registration (#30921)#30984

Open
Linux2010 wants to merge 4 commits into
NousResearch:mainfrom
Linux2010:fix/provider-duplicate-name-warning-30921
Open

fix(providers): warn on duplicate name/alias registration (#30921)#30984
Linux2010 wants to merge 4 commits into
NousResearch:mainfrom
Linux2010:fix/provider-duplicate-name-warning-30921

Conversation

@Linux2010

Copy link
Copy Markdown
Contributor

What broke

register_provider() in providers/__init__.py silently overwrites entries in _REGISTRY and _ALIASES when duplicate names or aliases are registered. This is common when users add custom model-provider plugins, but there is no warning or doctor output — the last registration silently wins with no visibility.

Root cause

register_provider() at lines 53-62 has no existence check or logging before inserting into _REGISTRY[profile.name] and _ALIASES[alias]. Users have no way to know which profile is active when names collide.

Why this fix is minimal

Two simple guards added to register_provider():

  • If profile.name is already in _REGISTRY, log a warning showing which module registered first and which is re-registering.
  • If any alias is already mapped to a different canonical name, log a warning showing the old and new mapping.

No behavior change — duplicate registrations still win (last-writer-wins), but now users are informed. No changes to discovery order, _ALIASES structure, or any other module.

What I tested

Added two new tests in tests/providers/test_provider_profiles.py:

  • test_duplicate_name_warns — verifies warning is logged when same name is re-registered
  • test_duplicate_alias_warns — verifies warning is logged when an overlapping alias is remapped, and that the alias is correctly updated

What I intentionally did not change

  • Last-writer-wins behavior (user plugins should still be able to override bundled profiles)
  • Discovery order or any other module
  • hermes doctor output (can be a follow-up PR to surface active overrides)

@alt-glitch alt-glitch added type/bug Something isn't working P3 Low — cosmetic, nice to have comp/plugins Plugin system and bundled plugins labels May 23, 2026
@alt-glitch

Copy link
Copy Markdown
Collaborator

Competing fix with #30937 — both address #30921 (duplicate name/alias registration warning). Please coordinate to avoid duplicate work.

Linux2010 and others added 2 commits May 28, 2026 14:07
…ch#30921)

register_provider() in providers/__init__.py silently overwrote entries
in _REGISTRY and _ALIASES when duplicate names or aliases were
registered (common with custom model-provider plugins). This made
conflicts invisible — users had no way to know which profile was active.

Fix: add existence checks before insertion:
- If profile.name is already in _REGISTRY, log a warning showing which
  module registered first and which module is re-registering.
- If any alias is already mapped to a different canonical name, log a
  warning showing the old and new mapping.

Test: add test_duplicate_name_warns and test_duplicate_alias_warns to
tests/providers/test_provider_profiles.py using caplog.
The tests assumed nvidia and openrouter were already registered, but
discovery must be triggered first. Also switch alias test to use
nvidia-nim which reliably exists after discovery.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
@Linux2010 Linux2010 force-pushed the fix/provider-duplicate-name-warning-30921 branch from 402dd00 to a7dfcbc Compare May 28, 2026 06:11
Linux2010 and others added 2 commits May 31, 2026 11:26
- Add linux2010@github.com to AUTHOR_MAP for check-attribution
- Restore original nvidia profile after test_duplicate_name_warns
- Cleanup __test_override__ and restore nvidia-nim alias after
  test_duplicate_alias_warns to prevent breaking TestNvidiaProfile tests

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

comp/plugins Plugin system and bundled plugins P3 Low — cosmetic, nice to have type/bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants