Repository navigation
fix(ui): require new expiration when regenerating an expired key #29838
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
ryan-crabbe-berri
merged 5 commits into
litellm_internal_staging
from
litellm_regenerate_expired_key_ui
Jun 6, 2026
Merged
Changes from 1 commit
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
b00f81a
fix(ui): require new expiration when regenerating an expired key
milan-berri 5399e05
style(ui): fix prettier formatting in RegenerateKeyModal tests
milan-berri 9559cb1
refactor(ui): address review feedback on expired-key regenerate
milan-berri 27674aa
fix(ui): use API ISO expires for regenerate optimistic update
milan-berri f527f5b
fix(ui): don't toast Ant form validation errors on regenerate
milan-berri File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,30 @@ | ||
| import { afterEach, describe, expect, it, vi } from "vitest"; | ||
| import { isKeyExpired, parseExpiresUtc } from "./keyExpiryUtils"; | ||
|
|
||
| describe("keyExpiryUtils", () => { | ||
| afterEach(() => { | ||
| vi.restoreAllMocks(); | ||
| }); | ||
|
|
||
| it("treats naive ISO strings as UTC", () => { | ||
| const ms = parseExpiresUtc("2020-01-01T12:00:00"); | ||
| expect(ms).toBe(Date.parse("2020-01-01T12:00:00Z")); | ||
| }); | ||
|
|
||
| it("parses Z-suffixed ISO strings unchanged", () => { | ||
| const iso = "2020-01-01T12:00:00.000Z"; | ||
| expect(parseExpiresUtc(iso)).toBe(Date.parse(iso)); | ||
| }); | ||
|
|
||
| it("returns false when expires is missing", () => { | ||
| expect(isKeyExpired(undefined)).toBe(false); | ||
| expect(isKeyExpired(null)).toBe(false); | ||
| }); | ||
|
|
||
| it("detects expired keys using UTC comparison", () => { | ||
| vi.spyOn(Date, "now").mockReturnValue(Date.parse("2026-06-06T12:00:00Z")); | ||
| expect(isKeyExpired("2026-06-05T12:00:00Z")).toBe(true); | ||
| expect(isKeyExpired("2026-06-06T12:00:00")).toBe(false); | ||
| expect(isKeyExpired("2026-06-07T12:00:00Z")).toBe(false); | ||
| }); | ||
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,21 @@ | ||
| const HAS_TIMEZONE_SUFFIX = /[zZ]$|[+-]\d{2}:?\d{2}$/; | ||
|
|
||
| /** | ||
| * Parse a key expires timestamp as UTC, matching proxy auth behavior for naive DB values. | ||
| */ | ||
| export function parseExpiresUtc(expires: string): number { | ||
| const normalized = HAS_TIMEZONE_SUFFIX.test(expires) ? expires : `${expires}Z`; | ||
| return Date.parse(normalized); | ||
| } | ||
|
|
||
| /** | ||
| * Returns true when the key has an expires value in the past (UTC). | ||
| */ | ||
| export function isKeyExpired(expires?: string | null): boolean { | ||
| if (!expires) { | ||
| return false; | ||
| } | ||
|
|
||
| const expiryMs = parseExpiresUtc(expires); | ||
| return !Number.isNaN(expiryMs) && expiryMs < Date.now(); | ||
| } |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.