Repository navigation
fix: /api/models/live skips probe for custom providers with model config (#3718) #3719
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
DanielMaly
wants to merge
4
commits into
nesquena:master
from
DanielMaly:fix/3718-live-models-skip-custom-probe
Closed
Changes from 1 commit
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
14fbb84
fix: always probe live endpoint for custom providers (#3718)
DanielMaly 1669c5e
test: rewrite #3718 tests as behavioral instead of source-string checks
DanielMaly f663309
merge: resolve CHANGELOG.md conflict with v0.51.293
DanielMaly 2dfed38
fix: address maintainer review feedback on #3719
DanielMaly File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,42 @@ | ||
| """Regression test for #3718 -- /api/models/live skips probe for custom providers. | ||
|
|
||
| When a custom provider (``custom_providers`` entry in config.yaml) has a | ||
| ``model:`` field but no ``models:`` allowlist, the live endpoint previously | ||
| populated ``ids`` from the config entry and then skipped the live ``/v1/models`` | ||
| probe (guarded by ``if not ids``). The fix collects config-specified model IDs | ||
| in a separate ``_config_ids`` list so the live fetch always runs, and merges | ||
| config entries as a fallback after the fetch. | ||
| """ | ||
| import pathlib | ||
|
|
||
| ROUTES_PY = (pathlib.Path(__file__).parent.parent / "api" / "routes.py").read_text(encoding="utf-8") | ||
|
|
||
|
|
||
| class TestLiveModelsCustomProviderProbe: | ||
| """Live endpoint must probe the upstream /v1/models even when config has entries.""" | ||
|
|
||
| def test_config_ids_collected_separately(self): | ||
| """Config-specified model IDs must go into ``_config_ids``, not ``ids``.""" | ||
| assert "_config_ids" in ROUTES_PY, ( | ||
| "routes.py must collect config model IDs in _config_ids, not ids (#3718)" | ||
| ) | ||
|
|
||
| def test_live_fetch_not_guarded_by_ids(self): | ||
| """The live fetch must not be guarded by ``if not ids`` for custom providers.""" | ||
| # The old code had: if not ids and (provider == "custom" ... | ||
| # The fix changes it to: if provider == "custom" ... | ||
| # Verify the guard ``not ids`` is NOT present before the custom-provider block. | ||
| live_fetch_section = ROUTES_PY[ROUTES_PY.find("Always try live fetch for custom providers"):] | ||
| assert "if not ids and" not in live_fetch_section.split("OpenAI-compat live fetch fallback")[0], ( | ||
| "Live fetch for custom providers must not be guarded by 'if not ids' (#3718)" | ||
| ) | ||
|
|
||
| def test_merge_logic_after_live_fetch(self): | ||
| """After the live fetch, config entries must be merged (not replaced).""" | ||
| merge_section = ROUTES_PY[ROUTES_PY.find("live fetch succeeded, merge"):] | ||
| assert "_live_set = set(ids)" in merge_section, ( | ||
| "Live fetch results must take priority over config entries (#3718)" | ||
| ) | ||
| assert "ids.append(_cid)" in merge_section, ( | ||
| "Config entries not already in live results must be appended (#3718)" | ||
| ) | ||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.