fix(ui): prevent destructure crash in Auto Router test connection

prepareModelAddRequest returns an empty array for auto router forms
(no model_mappings field), causing result[0] to be undefined when
destructuring litellmParamsObj.

Two fixes:
- Guard against empty result array in model_connection_test.tsx
- Pass properly constructed model_mappings from the auto router tab
  so test connection actually works for auto routers
This commit is contained in:
devin-ai-integration[bot] 2026-07-01 04:07:25 +00:00 • committed by GitHub
parent 70eb4e5d00
commit c2dbe5826d
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 11 additions and 3 deletions

View file

@ -436,11 +436,19 @@ const AddAutoRouterTab: React.FC<AddAutoRouterTabProps> = ({ form, handleOk, acc
]}
width={700}
>
{/* Only render the ConnectionErrorDisplay when modal is visible and we have a test ID */}
{isResultModalVisible && (
<ConnectionErrorDisplay
key={connectionTestId}
formValues={form.getFieldsValue()}
formValues={{
...form.getFieldsValue(),
custom_llm_provider: "auto_router",
model_mappings: [{
public_name: form.getFieldValue("auto_router_name") || "auto_router",
litellm_model: routerType === "complexity"
? "auto_router/complexity_router"
: `auto_router/${form.getFieldValue("auto_router_name") || "auto_router"}`,
}],
}}
accessToken={accessToken}
testMode="chat"
modelName={form.getFieldValue("auto_router_name")}

View file

@ -45,7 +45,7 @@ const ModelConnectionTest: React.FC<ModelConnectionTestProps> = ({
console.log("Testing connection with form values:", formValues);
const result = await prepareModelAddRequest(formValues, accessToken, null);
if (!result) {
if (!result || result.length === 0) {
console.log("No result from prepareModelAddRequest");
setError("Failed to prepare model data. Please check your form inputs.");
setIsSuccess(false);