mirror of
https://github.com/BerriAI/litellm.git
synced 2026-09-11 22:51:28 +00:00
[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 <noreply@anthropic.com>
This commit is contained in:
parent
4b8b7bb557
commit
6c8eea67a5
2 changed files with 12 additions and 5 deletions
|
|
@ -350,9 +350,11 @@ const CreateKey: React.FC<CreateKeyProps> = ({ 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<CreateKeyProps> = ({ team, teams, data, addKey }) => {
|
|||
/>
|
||||
</div>
|
||||
</AccordionBody>
|
||||
<Form.Item name="duration" hidden initialValue={null}>
|
||||
<Form.Item name="duration" hidden>
|
||||
<Input />
|
||||
</Form.Item>
|
||||
</Accordion>
|
||||
|
|
|
|||
|
|
@ -263,6 +263,11 @@ export function KeyEditView({
|
|||
}
|
||||
// If it's already an array (shouldn't happen, but handle it), keep as is
|
||||
|
||||
// Handle duration: null = Never Expires (keep); empty string or undefined = not changed (omit)
|
||||
if (values.duration !== null && (!values.duration || values.duration.trim() === "")) {
|
||||
delete values.duration;
|
||||
}
|
||||
|
||||
await onSubmit(values);
|
||||
} finally {
|
||||
setIsKeySaving(false);
|
||||
|
|
@ -659,7 +664,7 @@ export function KeyEditView({
|
|||
rotationInterval={rotationInterval}
|
||||
onRotationIntervalChange={setRotationInterval}
|
||||
/>
|
||||
<Form.Item name="duration" hidden initialValue="">
|
||||
<Form.Item name="duration" hidden>
|
||||
<Input />
|
||||
</Form.Item>
|
||||
</div>
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue