From 6da4e0b9018fdbb2fc9345e00b518fa8a5c57050 Mon Sep 17 00:00:00 2001 From: Ryan Crabbe Date: Tue, 14 Apr 2026 10:13:58 -0700 Subject: [PATCH] fix(ui): pre-select backend default for boolean guardrail provider fields MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Boolean fields in the auto-generated guardrail provider form (e.g. Noma `use_v2`) rendered as empty Selects because the Form.Item only populated `initialValue` for percentage fields, and the `defaultValue` passed to the Select child was silently dropped by antd's controlled-component wrapper. Users could not tell what the backend default was, and the visual ambiguity made flags like `use_v2` look inoperative even though the save path worked. Unify `initialValue` to fall back through `fieldValue → field.default_value → (percentage ? 0.5 : undefined)`, and switch Select.Option values from "true"/"false" strings to real booleans so the backend default flows through without stringification. --- .../guardrails/guardrail_provider_fields.tsx | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) diff --git a/ui/litellm-dashboard/src/components/guardrails/guardrail_provider_fields.tsx b/ui/litellm-dashboard/src/components/guardrails/guardrail_provider_fields.tsx index 2bc381c8e8..7e9568c04d 100644 --- a/ui/litellm-dashboard/src/components/guardrails/guardrail_provider_fields.tsx +++ b/ui/litellm-dashboard/src/components/guardrails/guardrail_provider_fields.tsx @@ -157,10 +157,10 @@ const GuardrailProviderFields: React.FC = ({ ); } - const percentageInitialValue = - field.type === "percentage" && (fieldValue === undefined || fieldValue === null) - ? (field.default_value ?? 0.5) - : undefined; + const resolvedInitialValue = + fieldValue !== undefined + ? fieldValue + : (field.default_value ?? (field.type === "percentage" ? 0.5 : undefined)); return ( = ({ label={fieldKey} tooltip={field.description} rules={field.required ? [{ required: true, message: `${fieldKey} is required` }] : undefined} - initialValue={percentageInitialValue} + initialValue={resolvedInitialValue} > {field.type === "select" && field.options ? ( ) : field.type === "bool" || field.type === "boolean" ? ( - + True + False ) : field.type === "percentage" && field.min != null && field.max != null ? (