From e8b289e0ed4af573f2d21dd5ea949554907924da Mon Sep 17 00:00:00 2001 From: milan Date: Fri, 21 Aug 2026 15:58:20 +0000 Subject: [PATCH] refactor(ui): move deleted-extra-param null handling into ModelInfoEditForm Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com> --- .../src/components/ModelInfoEditForm.tsx | 15 +++++++++++++++ .../src/components/model_info_view.tsx | 11 ++--------- 2 files changed, 17 insertions(+), 9 deletions(-) diff --git a/ui/litellm-dashboard/src/components/ModelInfoEditForm.tsx b/ui/litellm-dashboard/src/components/ModelInfoEditForm.tsx index 83ba4ade340..c84f61dd814 100644 --- a/ui/litellm-dashboard/src/components/ModelInfoEditForm.tsx +++ b/ui/litellm-dashboard/src/components/ModelInfoEditForm.tsx @@ -214,6 +214,21 @@ export const editableExtraParams = ( ), ); +// Keys the user deleted from the LiteLLM Params JSON editor must be sent as +// explicit nulls: the backend PATCH merges params, so an absent key would +// silently keep its old value. +export const applyNullsForDeletedExtraParams = ( + updatedLitellmParams: Record, + storedLitellmParams: Record | null | undefined, + parsedExtraParams: Record, +): void => { + for (const key of Object.keys(editableExtraParams(storedLitellmParams))) { + if (!(key in parsedExtraParams) && updatedLitellmParams[key] === undefined) { + updatedLitellmParams[key] = null; + } + } +}; + export const toModelEditFormValues = (localModelData: any, isWildcardModel: boolean): ModelEditFormValues => ({ model_name: localModelData.model_name, litellm_model_name: localModelData.litellm_model_name, diff --git a/ui/litellm-dashboard/src/components/model_info_view.tsx b/ui/litellm-dashboard/src/components/model_info_view.tsx index 37855b8a262..4ea2d65984b 100644 --- a/ui/litellm-dashboard/src/components/model_info_view.tsx +++ b/ui/litellm-dashboard/src/components/model_info_view.tsx @@ -43,7 +43,7 @@ import { import { Logo } from "@/components/molecules/logo/Logo"; import UpdateModelCredentialsModal from "./update_model_credentials_modal"; import ModelInfoEditForm, { - editableExtraParams, + applyNullsForDeletedExtraParams, type ModelEditFormValues, type TouchedPricingField, } from "./ModelInfoEditForm"; @@ -430,14 +430,7 @@ export default function ModelInfoView({ return; } - // Keys the user deleted from the LiteLLM Params JSON editor must be sent as - // explicit nulls: the backend PATCH merges params, so an absent key would - // silently keep its old value. - for (const key of Object.keys(editableExtraParams(localModelData?.litellm_params))) { - if (!(key in parsedExtraParams) && updatedLitellmParams[key] === undefined) { - updatedLitellmParams[key] = null; - } - } + applyNullsForDeletedExtraParams(updatedLitellmParams, localModelData?.litellm_params, parsedExtraParams); // Final guard: never PATCH a redacted secret. The /model/info snapshot that // seeds this form masks secrets, and any save re-sends the whole params blob;