From 6c8eea67a5e9ecd392488ff3a42e477697580159 Mon Sep 17 00:00:00 2001 From: yuneng-jiang Date: Thu, 5 Mar 2026 15:27:29 -0800 Subject: [PATCH] [Fix] Key Expiry: omit duration from payload when not set by user - create_key_button: remove initialValue={null} on hidden duration field; change submit handler to delete duration when empty/undefined rather than converting to null, so untouched expiry settings don't accidentally trigger never-expires behavior on the backend. - key_edit_view: remove initialValue="" on hidden duration field; add same duration cleanup to handleSubmit so an untouched field sends no duration key instead of an empty string. - In both cases duration: null is preserved (Never Expires checkbox). Co-Authored-By: Claude Sonnet 4.6 --- .../src/components/organisms/create_key_button.tsx | 10 ++++++---- .../src/components/templates/key_edit_view.tsx | 7 ++++++- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/ui/litellm-dashboard/src/components/organisms/create_key_button.tsx b/ui/litellm-dashboard/src/components/organisms/create_key_button.tsx index 802dfd14b63..bfc545cd701 100644 --- a/ui/litellm-dashboard/src/components/organisms/create_key_button.tsx +++ b/ui/litellm-dashboard/src/components/organisms/create_key_button.tsx @@ -350,9 +350,11 @@ const CreateKey: React.FC = ({ team, teams, data, addKey }) => { formValues.rotation_interval = rotationInterval; } - // Handle duration field for key expiry - convert empty string to null - if (!formValues.duration || formValues.duration.trim() === "") { - formValues.duration = null; + // Handle duration field for key expiry: + // - null means Never Expires (explicitly set by checkbox) — keep as-is + // - empty string or undefined means not provided — omit entirely + if (formValues.duration !== null && (!formValues.duration || formValues.duration.trim() === "")) { + delete formValues.duration; } // Update the formValues with the final metadata @@ -1407,7 +1409,7 @@ const CreateKey: React.FC = ({ team, teams, data, addKey }) => { /> -