Repository navigation
fix(studio): return 404 for mistyped GGUF model ids on /v1 API - #8389
danielhanchen merged 5 commits into
Conversation
Treat unsloth/ and -GGUF hub repo ids as concrete references so a wrong model name is refused instead of being answered by the loaded model. Fixes unslothai#8376.
|
Pushed a one line change to this branch. The helper and the reject gate are good, but the Backend CI was red on all four interpreters. Reproduced locally against the full suite on the previous head: That handler runs when the local model scan throws, and at that point we cannot tell "not downloaded" apart from "the scan broke". Refusing a catalog shaped id there returns 404 with a message saying the model is not downloaded on this server, which is exactly the thing we just failed to verify. Before this PR the fail closed path covered explicit quants only, where the blast radius is small. Extending it to the whole Dropping
Full backend suite on the new head: 21315 passed, 130 skipped, 36 deselected. Two things to settle before this goes in.
Also worth a rebase, the branch is a good way behind main now. |
The looks_like_gguf_hub_repo_id helper also gates Transformers-backed Studio entries, not just -GGUF repos. Update the docstring accordingly.
|
Thanks for the review and for pushing the fail-open fix — that makes sense; extending the Pulled your commit and updated the On the two open points: agree the carve-out is the right call (foreign provider labels still fall through), and happy for @Lyxot to confirm on #8376. Branch is rebased on current |
|
@codex review |
|
Thanks for the docstring update, that settles point 2 well. Pushed one more fix on top. Simulating the gate across the full product of id shape x loaded backend x resolver state x auto-switch x index-built x POSIX/NT path semantics (7168 cells per tree) turned up a second regression that the unit tests did not reach: a model loaded from a local directory gets 404d under its own hub id, while it is the model actually serving.
The fix keeps the promotion but makes it decisive only against a resident that carries a hub-style id of its own. An HF cache path still maps back to Behaviour across the three trees, same 7168 cells each, diffed against the merge base:
Every remaining change is a mistyped catalog id becoming a 404. Foreign labels ( I also drove every model-bearing surface end to end rather than just chat, since the gate is shared. On the merge base all six answered a mistyped id with the resident model, so the original report understated the scope: Two regression tests added, both of which fail on the previous head with the misleading message above. Full backend suite: 21317 passed, 130 skipped, 36 deselected. One note on scope for whoever merges: this is still a deliberate change to the drop-in alias behaviour that #8376 was closed under, now covering the whole |
|
Codex Review: Didn't find any major issues. Hooray! Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
Fixes #8376
Summary
When a client called
/v1/chat/completions(or other OpenAI-compatible endpoints) with a model name that was not loaded — for example a mistyped vision model id — the server silently routed the request to whatever model was already in memory. The client then got misleading errors (e.g. "Image provided but current GGUF model does not support vision") instead of a clearmodel_not_foundresponse.This change refuses mistyped or missing GGUF catalog model ids instead of answering with the wrong weights.
Root cause
_reject_unservable_model()only refused a named model when it looked like an explicit quant (:Q4_K_M) or was already known locally (here). A bare hub-style id likeunsloth/typo-vision-GGUFthat was not downloaded and not in the catalog fell through to drop-in OpenAI compatibility — so the loaded text model answered the request.Fix
looks_like_gguf_hub_repo_id()inopenai_auto_download.pyto detect ids that clearly target this server's GGUF catalog:-GGUFunsloth/namespace_reject_unservable_model()to treat those ids as concrete references and return 404model_not_foundwhen they do not match the loaded model.LiteLLM / OpenRouter-style labels (
openai/gpt-4o,anthropic/claude-3.5-sonnet, etc.) still fall through to the loaded model for drop-in compatibility.Files changed
studio/backend/core/inference/openai_auto_download.pylooks_like_gguf_hub_repo_id()helperstudio/backend/routes/inference.py_reject_unservable_model()studio/backend/tests/test_openai_auto_download.pystudio/backend/tests/test_openai_auto_switch.pyTest plan
pytest tests/test_openai_auto_download.py::test_looks_like_gguf_hub_repo_idpytest tests/test_openai_auto_download.py::test_a_mistyped_gguf_repo_is_refused_while_another_model_is_loadedpytest tests/test_openai_auto_switch.py::test_chat_mistyped_gguf_repo_404s_before_vision_guardopenai/gpt-4o, etc.) still fall throughorg/Unlistedids not in catalog still fall through