refactor(ui): move deleted-extra-param null handling into ModelInfoEditForm

Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
This commit is contained in:
milan 2026-08-21 15:58:20 +00:00
parent d01537c1bb
commit e8b289e0ed
2 changed files with 17 additions and 9 deletions

View file

@ -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<string, any>,
storedLitellmParams: Record<string, unknown> | null | undefined,
parsedExtraParams: Record<string, any>,
): 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,

View file

@ -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;