Skip to content

The fastest, litest AI Gateway. Rust core with Python SDK. Call 100+ LLM APIs in OpenAI (or native) format with cost tracking, guardrails, load balancing, and logging [Bedrock, Azure, OpenAI, Anthropic, OpenAI, VertexAI, vLLM, Nvidia NIM]

Improve e2e flow for cloudzero

yuneng-jiange92db2d718a7
diff --git a/ui/litellm-dashboard/src/app/(dashboard)/hooks/cloudzero/useCloudZeroSettings.ts b/ui/litellm-dashboard/src/app/(dashboard)/hooks/cloudzero/useCloudZeroSettings.ts
index 5ccbe244e60..96f5ab2f944 100644
--- a/ui/litellm-dashboard/src/app/(dashboard)/hooks/cloudzero/useCloudZeroSettings.ts
+++ b/ui/litellm-dashboard/src/app/(dashboard)/hooks/cloudzero/useCloudZeroSettings.ts
@@ -17,19 +17,35 @@ const getCloudZeroSettings = async (accessToken: string): Promise<CloudZeroSetti
},
});
- if (response.status === 404) {
- // 404 means no settings are configured - this is expected and not an error
- return null;
- }
-
if (!response.ok) {
- const errorData = await response.json().catch(() => ({}));
- const errorMessage =
- errorData?.error?.message || errorData?.message || errorData?.detail || "Failed to fetch CloudZero settings";
+ let errorMessage = "Failed to fetch CloudZero settings";
+ try {
+ const errorData = await response.json();
+ // Handle different error response formats
+ if (typeof errorData === "object" && errorData !== null) {
+ errorMessage =
+ errorData?.error?.message ||
+ errorData?.error ||
+ errorData?.message ||
+ errorData?.detail ||
+ (typeof errorData?.error === "string" ? errorData.error : errorMessage);
+ } else if (typeof errorData === "string") {
+ errorMessage = errorData;
+ }
+ } catch {
+ // If JSON parsing fails, use the status text
+ errorMessage = response.statusText || errorMessage;
+ }
throw new Error(errorMessage);
}
const data = await response.json();
+
+ // Check if settings are actually configured (all required fields are present)
+ if (!data || (!data.api_key_masked && !data.connection_id)) {
+ return null;
+ }
+
return data;
};
@@ -77,9 +93,22 @@ const updateCloudZeroSettings = async (accessToken: string, params: UpdateParams
});
if (!response.ok) {
- const errorData = await response.json().catch(() => ({}));
- const errorMessage =
- errorData?.error?.message || errorData?.message || errorData?.detail || "Failed to update CloudZero settings";
+ let errorMessage = "Failed to update CloudZero settings";
+ try {
+ const errorData = await response.json();
+ if (typeof errorData === "object" && errorData !== null) {
+ errorMessage =
+ errorData?.error?.message ||
+ errorData?.error ||
+ errorData?.message ||
+ errorData?.detail ||
+ (typeof errorData?.error === "string" ? errorData.error : errorMessage);
+ } else if (typeof errorData === "string") {
+ errorMessage = errorData;
+ }
+ } catch {
+ errorMessage = response.statusText || errorMessage;
+ }
throw new Error(errorMessage);
}
@@ -117,9 +146,22 @@ const deleteCloudZeroSettings = async (accessToken: string): Promise<DeleteRespo
});
if (!response.ok) {
- const errorData = await response.json().catch(() => ({}));
- const errorMessage =
- errorData?.error?.message || errorData?.message || errorData?.detail || "Failed to delete CloudZero settings";
+ let errorMessage = "Failed to delete CloudZero settings";
+ try {
+ const errorData = await response.json();
+ if (typeof errorData === "object" && errorData !== null) {
+ errorMessage =
+ errorData?.error?.message ||
+ errorData?.error ||
+ errorData?.message ||
+ errorData?.detail ||
+ (typeof errorData?.error === "string" ? errorData.error : errorMessage);
+ } else if (typeof errorData === "string") {
+ errorMessage = errorData;
+ }
+ } catch {
+ errorMessage = response.statusText || errorMessage;
+ }
throw new Error(errorMessage);
}
diff --git a/ui/litellm-dashboard/src/components/CloudZeroCostTracking/CloudZeroCostTracking.tsx b/ui/litellm-dashboard/src/components/CloudZeroCostTracking/CloudZeroCostTracking.tsx
index fbb892cb1d8..db3ea94bbf9 100644
--- a/ui/litellm-dashboard/src/components/CloudZeroCostTracking/CloudZeroCostTracking.tsx
+++ b/ui/litellm-dashboard/src/components/CloudZeroCostTracking/CloudZeroCostTracking.tsx
@@ -36,7 +36,9 @@ export default function CloudZeroCostTracking() {
if (error) {
return (
<Card>
- <Typography.Text className="text-red-600">Error loading CloudZero settings: {error.message}</Typography.Text>
+ <Typography.Text className="text-red-600">
+ Error loading CloudZero settings: {error instanceof Error ? error.message : String(error)}
+ </Typography.Text>
</Card>
);
}
diff --git a/ui/litellm-dashboard/src/components/CloudZeroCostTracking/CloudZeroEmptyPlaceholder.test.tsx b/ui/litellm-dashboard/src/components/CloudZeroCostTracking/CloudZeroEmptyPlaceholder.test.tsx
index 04e0a67dea6..f7b90884006 100644
--- a/ui/litellm-dashboard/src/components/CloudZeroCostTracking/CloudZeroEmptyPlaceholder.test.tsx
+++ b/ui/litellm-dashboard/src/components/CloudZeroCostTracking/CloudZeroEmptyPlaceholder.test.tsx
@@ -9,6 +9,6 @@ describe("CloudZeroEmptyPlaceholder", () => {
expect(screen.getByText("No CloudZero Integration Found")).toBeInTheDocument();
expect(screen.getByText(/Connect your CloudZero account/)).toBeInTheDocument();
- expect(screen.getByRole("button", { name: "Create Integration" })).toBeInTheDocument();
+ expect(screen.getByRole("button", { name: "Add CloudZero Integration" })).toBeInTheDocument();
});
});
diff --git a/ui/litellm-dashboard/src/components/CloudZeroCostTracking/CloudZeroEmptyPlaceholder.tsx b/ui/litellm-dashboard/src/components/CloudZeroCostTracking/CloudZeroEmptyPlaceholder.tsx
index 1719a949b86..aca074dc290 100644
--- a/ui/litellm-dashboard/src/components/CloudZeroCostTracking/CloudZeroEmptyPlaceholder.tsx
+++ b/ui/litellm-dashboard/src/components/CloudZeroCostTracking/CloudZeroEmptyPlaceholder.tsx
@@ -21,7 +21,7 @@ export default function CloudZeroEmptyPlaceholder({ startCreation }: CloudZeroEm
}
>
<Button type="primary" size="large" onClick={startCreation} className="flex items-center gap-2 mx-auto mt-4">
- Create Integration
+ Add CloudZero Integration
</Button>
</Empty>
</div>
diff --git a/ui/litellm-dashboard/src/components/CloudZeroCostTracking/CloudZeroIntegrationSettings.tsx b/ui/litellm-dashboard/src/components/CloudZeroCostTracking/CloudZeroIntegrationSettings.tsx
index 780fa83652a..c161d241f7d 100644
--- a/ui/litellm-dashboard/src/components/CloudZeroCostTracking/CloudZeroIntegrationSettings.tsx
+++ b/ui/litellm-dashboard/src/components/CloudZeroCostTracking/CloudZeroIntegrationSettings.tsx
@@ -134,10 +134,14 @@ export function CloudZeroIntegrationSettings({ settings, onSettingsUpdated }: Cl
}}
>
<Descriptions.Item label="API Key (Redacted)">
- <span className="font-mono text-gray-600">{settings.api_key_masked}</span>
+ <span className="font-mono text-gray-600">
+ {settings.api_key_masked || <span className="text-gray-400 italic">Not configured</span>}
+ </span>
</Descriptions.Item>
<Descriptions.Item label="Connection ID">
- <span className="font-mono text-gray-600">{settings.connection_id}</span>
+ <span className="font-mono text-gray-600">
+ {settings.connection_id || <span className="text-gray-400 italic">Not configured</span>}
+ </span>
</Descriptions.Item>
<Descriptions.Item label="Timezone">
{settings.timezone || <span className="text-gray-400 italic">Default (UTC)</span>}
diff --git a/ui/litellm-dashboard/src/components/CloudZeroCostTracking/types.ts b/ui/litellm-dashboard/src/components/CloudZeroCostTracking/types.ts
index a41afee4f72..ed3c76cc3b1 100644
--- a/ui/litellm-dashboard/src/components/CloudZeroCostTracking/types.ts
+++ b/ui/litellm-dashboard/src/components/CloudZeroCostTracking/types.ts
@@ -1,6 +1,6 @@
export interface CloudZeroSettings {
- api_key_masked: string;
- connection_id: string;
- timezone?: string;
- status?: string;
+ api_key_masked: string | null;
+ connection_id: string | null;
+ timezone?: string | null;
+ status?: string | null;
}