mirror of
https://github.com/BerriAI/litellm.git
synced 2026-10-08 03:08:45 +00:00
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:
parent
70eb4e5d00
commit
c2dbe5826d
2 changed files with 11 additions and 3 deletions
|
|
@ -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")}
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue