Fix _norm_model_id to properly strip provider prefixes#1454
Fix _norm_model_id to properly strip provider prefixes#1454happy5318 wants to merge 1 commit intonesquena:masterfrom
Conversation
The _norm_model_id function was using split(':', 1)[1] which only removed
the first colon-separated segment, leaving provider names in the normalized
model ID. For example, '@Custom:jingdong:GLM-5' became 'jingdong:glm.5'
instead of 'glm.5'.
This caused the default model injection check to fail, resulting in a
duplicate 'Default' group being added to the model list even when the
model already existed with a provider prefix.
Changes:
- Use split(':')[-1] to get the last segment after all colons
- Use split('/')[-1] consistently for slash-separated paths
- Replace local _norm lambda with _norm_model_id function call
Fixes duplicate Default group appearing in model dropdown when using
custom providers with @Provider:model ID format.
|
Thanks for filing the matching issue + PR with reproduction details — the bug is real and the diagnosis matches what I see in One concern with the proposed fix that I'd want addressed before merge:
That collapses every A more conservative shape that handles if s.startswith("@") and ":" in s:
parts = s.split(":")
# @custom:<provider>:<model...> → strip both prefix segments
if len(parts) >= 3 and parts[0] == "@custom":
s = ":".join(parts[2:])
else:
# @<provider>:<model...> → strip only the @provider segment
s = parts[1] if len(parts) == 2 else ":".join(parts[1:])Or, if the intent is "strip every leading while s.startswith("@") and ":" in s:
s = s.split(":", 1)[1]That second form handles Either way, this PR would benefit from two test cases in
The claim that "all 20 existing tests pass" is good, but those tests don't appear to cover either of these code paths, so they wouldn't catch the regression I'm describing. Direction is right, just want to make sure we don't trade one dedup bug for another. cc @nesquena for the merge call. |
|
Thanks @happy5318 — both this fix and the frontend mirror in #1474 shipped in v0.50.267 via release PR #1475. The work landed in master via the stage-267 batch (GitHub's auto-close didn't recognize this PR's commits through the no-ff merge, so closing manually). Thanks for the persistence — the multi-segment provider-prefix bug had been latent for several releases and the trailing-empty edge case got an Opus advisor follow-up that hardened both the backend and frontend helpers symmetrically. Closes #1453. |
…w-up - CHANGELOG.md: v0.50.267 entry detailing nesquena#1454/nesquena#1474/nesquena#1461/nesquena#1465/nesquena#1467/nesquena#1460/nesquena#1473 + Opus advisor SHOULD-FIX trailing-empty guard for _norm_model_id - ROADMAP.md: bump to v0.50.267, 3776 tests collected - TESTING.md: bump header + total to 3776 - api/config.py: trailing-empty fallback in _norm_model_id (parts[-1] or s) - static/ui.js: mirror trailing-empty fallback in _normalizeConfiguredModelKey - tests/test_norm_model_id_trailing_empty_guard.py: 5 regression tests
Summary
Fixes #1453
The
_norm_model_idfunction was usingsplit(':', 1)[1]which only removed the first colon-separated segment, leaving provider names in the normalized model ID.Problem
For
@custom:jingdong:GLM-5:jingdong:glm.5(incorrect)glm.5(correct)This caused the default model injection check to fail, resulting in a duplicate "Default" group being added to the model list.
Changes
_norm_model_id: Usesplit(':')[-1]to get the last segment after all colons_norm_model_id: Usesplit('/')[-1]consistently for slash-separated paths_normlambda with_norm_model_idfunction callTesting
tests/test_model_resolver.pypassBefore
Model dropdown would show:
After
Model dropdown correctly shows: