Merge pull request #15672 from BerriAI/litellm_key_max_budget_error_fix

[Fix] UI - Key Max Budget Removal Error Fix
This commit is contained in:
Ishaan Jaff 2025-10-17 12:15:20 -07:00 committed by GitHub
commit 8f710abe05
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 28 additions and 1 deletions

View file

@ -43,6 +43,7 @@ import { CheckIcon, CopyIcon } from "lucide-react";
import { copyToClipboard as utilCopyToClipboard } from "../../utils/dataUtils";
import NotificationsManager from "../molecules/notifications_manager";
import PassThroughRoutesSelector from "../common_components/PassThroughRoutesSelector";
import { mapEmptyStringToNull } from "@/utils/keyUpdateUtils";
export interface TeamMembership {
user_id: string;
@ -324,6 +325,8 @@ const TeamInfoView: React.FC<TeamInfoProps> = ({
organization_id: values.organization_id,
};
updateData.max_budget = mapEmptyStringToNull(updateData.max_budget);
if (values.team_member_budget !== undefined) {
updateData.team_member_budget = Number(values.team_member_budget);
}

View file

@ -16,6 +16,7 @@ import { CopyIcon, CheckIcon } from "lucide-react";
import { mapInternalToDisplayNames, mapDisplayToInternalNames } from "../callback_info_helpers";
import { parseErrorMessage } from "../shared/errorUtils";
import AutoRotationView from "../common_components/AutoRotationView";
import { mapEmptyStringToNull } from "@/utils/keyUpdateUtils";
interface KeyInfoViewProps {
keyId: string;
@ -107,6 +108,9 @@ export default function KeyInfoView({
delete formValues.prompts;
}
// Handle max budget empty string
formValues.max_budget = mapEmptyStringToNull(formValues.max_budget);
// Handle object_permission updates
if (formValues.vector_stores !== undefined) {
formValues.object_permission = {
@ -630,7 +634,8 @@ export default function KeyInfoView({
<div>
<Text className="font-medium">Allowed Pass Through Routes</Text>
<Text>
{Array.isArray(currentKeyData.metadata?.allowed_passthrough_routes) && currentKeyData.metadata.allowed_passthrough_routes.length > 0
{Array.isArray(currentKeyData.metadata?.allowed_passthrough_routes) &&
currentKeyData.metadata.allowed_passthrough_routes.length > 0
? currentKeyData.metadata.allowed_passthrough_routes.map((route, index) => (
<span key={index} className="px-2 mr-2 py-1 bg-blue-100 rounded text-xs">
{route}

View file

@ -0,0 +1,12 @@
import { describe, expect, it } from "vitest";
import { mapEmptyStringToNull } from "./keyUpdateUtils";
describe("keyUpdateUtils", () => {
it("should map empty string to null", () => {
expect(mapEmptyStringToNull("")).toBeNull();
});
it("should return the original string otherwise", () => {
expect(mapEmptyStringToNull("500")).toBe("500");
});
});

View file

@ -0,0 +1,7 @@
export function mapEmptyStringToNull(input: string): string | null {
if (input === "") {
return null;
}
return input;
}