Mintplex-Labs/anything-llm · warning · Error
Invalid model selection
Error message
Invalid model selection
What it means
Companion guard for non-router providers: validatedModelSelection(selectedLLMModel) must yield a usable model id, and a falsy result throws the localized 'model-router.chat.invalid-model' message ('Invalid model selection') before Workspace.update is called. It catches the case where the provider is chosen but no concrete model is set.
Source
Thrown at frontend/src/components/WorkspaceChat/ChatContainer/PromptInput/LLMSelector/index.jsx:101
async function handleSave() {
setSaving(true);
try {
setHasChanges(false);
const isRouter = selectedLLMProvider === "anythingllm-router";
if (isRouter && !selectedRouterId)
throw new Error(t("model-router.chat.select-router-error"));
const updateData = isRouter
? { chatProvider: selectedLLMProvider, router_id: selectedRouterId }
: {
chatProvider: selectedLLMProvider,
chatModel: validatedModelSelection(selectedLLMModel),
};
if (!isRouter && !updateData.chatModel)
throw new Error(t("model-router.chat.invalid-model"));
const { message } = await Workspace.update(slug, updateData);
if (!!message) throw new Error(message);
window.dispatchEvent(new Event(SAVE_LLM_SELECTOR_EVENT));
} catch (error) {
console.error(error);
showToast(error.message, "error", { clear: true });
} finally {
setSaving(false);
}
}
const providerName =
WORKSPACE_LLM_PROVIDERS.find((p) => p.value === selectedLLMProvider)
?.name || selectedLLMProvider;
if (loading) {View on GitHub (pinned to 3aec848f28)
Solutions
- Select a concrete model for the chosen provider before saving
- Add valid credentials for the provider so its model list populates, then pick a model
- For custom-model providers, type a non-empty model id in the input
Defensive patterns
Strategy: validation
Validate before calling
const model = selectedLLMProvider === "anythingllm-router" ? null : validatedModelSelection(selectedLLMModel); const canSave = selectedLLMProvider === "anythingllm-router" ? !!selectedRouterId : !!model; // disable Save when !canSave and flag the model dropdown
Try / catch
try { await handleSave(); }
catch (e) { if (e.message === t("model-router.chat.invalid-model")) highlightModelDropdown(); else throw e; } Prevention
- Require provider credentials to load the model list before enabling save
- Normalize placeholder model values ('all', '') to null so validation fails early and visibly
- Re-validate the model whenever the provider changes, not only on submit
When it happens
Trigger: A non-router provider is selected while its model value is empty, a placeholder that normalizes to null, or the model list never loaded (missing credentials) so nothing was chosen.
Common situations: Provider lacks an API key so the model dropdown stayed empty; custom-model input cleared; switching providers quickly and saving before the new model list resolves; model value filtered out by validation.
Related errors
- Select a router
- GroqAI:chatCompletion: ${this.model} is not valid for chat c
- GroqAI:streamChatCompletion: ${this.model} is not valid for
- ${message}
- data.message || "Error creating slash command preset."
AI-assisted analysis of Mintplex-Labs/anything-llm@3aec848f28 (2026-08-18).
Data as JSON: /api/errors/be4a4fe1272e6f34.
Report an issue: GitHub.