{"record":{"id":"a4620130649a3fe1","repo":"Mintplex-Labs/anything-llm","slug":"select-a-router","errorCode":null,"errorMessage":"Select a router","messagePattern":"Select a router","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"warning","filePath":"frontend/src/components/WorkspaceChat/ChatContainer/PromptInput/LLMSelector/index.jsx","lineNumber":91,"sourceCode":"  }\n\n  function handleProviderSelection(provider) {\n    setSelectedLLMProvider(provider);\n    setAvailableProviders(WORKSPACE_LLM_PROVIDERS);\n    autoScrollToSelectedLLMProvider(provider, 50);\n    document.getElementById(\"llm-search-input\").value = \"\";\n    setHasChanges(true);\n    setMissingCredentials(hasMissingCredentials(settings, provider));\n  }\n\n  async function handleSave() {\n    setSaving(true);\n    try {\n      setHasChanges(false);\n\n      const isRouter = selectedLLMProvider === \"anythingllm-router\";\n      if (isRouter && !selectedRouterId)\n        throw new Error(t(\"model-router.chat.select-router-error\"));\n\n      const updateData = isRouter\n        ? { chatProvider: selectedLLMProvider, router_id: selectedRouterId }\n        : {\n            chatProvider: selectedLLMProvider,\n            chatModel: validatedModelSelection(selectedLLMModel),\n          };\n\n      if (!isRouter && !updateData.chatModel)\n        throw new Error(t(\"model-router.chat.invalid-model\"));\n\n      const { message } = await Workspace.update(slug, updateData);\n\n      if (!!message) throw new Error(message);\n      window.dispatchEvent(new Event(SAVE_LLM_SELECTOR_EVENT));\n    } catch (error) {\n      console.error(error);\n      showToast(error.message, \"error\", { clear: true });","sourceCodeStart":73,"sourceCodeEnd":109,"githubUrl":"https://github.com/Mintplex-Labs/anything-llm/blob/3aec848f2885144aa8f1e53b9731a04310d5d558/frontend/src/components/WorkspaceChat/ChatContainer/PromptInput/LLMSelector/index.jsx#L73-L109","documentation":"Workspace chat LLM selector save guard. When the selected provider is 'anythingllm-router', saving requires a non-empty selectedRouterId; otherwise the localized 'model-router.chat.select-router-error' message (default text 'Select a router') is thrown before any API call is made.","triggerScenarios":"Provider dropdown set to anythingllm-router while the router sub-selection is empty — because no routers exist, the router list is still loading, or the user simply never picked one — and Save is clicked.","commonSituations":"No routers created yet in the model-router admin section; router fetch failed so the dropdown is empty; user switched provider to the router option and immediately saved.","solutions":["Pick a router in the router dropdown before saving","If no routers are listed, create one first in the model-router admin pages","Reload the page when the router list failed to load, then select and save"],"exampleFix":null,"handlingStrategy":"validation","validationCode":"const isRouter = selectedLLMProvider === \"anythingllm-router\";\nconst canSave = isRouter ? !!selectedRouterId : !!validatedModelSelection(selectedLLMModel);\n// <button disabled={!canSave} onClick={handleSave}>Save</button>","typeGuard":null,"tryCatchPattern":"try { await handleSave(); }\ncatch (e) { if (e.message === t(\"model-router.chat.select-router-error\")) highlightRouterDropdown(); else throw e; }","preventionTips":["Disable Save until the required router (or model) selection exists","Show an inline hint on the router dropdown when the list is empty or still loading","Validate the pair (provider + routerId/model) in one place before calling Workspace.update"],"tags":["llm-selector","model-router","validation","frontend"],"backgroundTag":"required-field-missing","analyzedSha":"3aec848f2885144aa8f1e53b9731a04310d5d558","analyzedAt":"2026-08-18T10:02:21.017Z","schemaVersion":2},"datasetVersion":"2026-08-21T18:17:14.833Z"}