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]
Python ai-gatewayanthropicazure-openaibedrockgatewaylangchainlitellmllmllm-gatewayllmopsmcp-gatewayopenaiopenai-proxyrustrust-aivertex-ai
fix: improve type safety and defensive guard in useOnboarding hook
yuneng-jiangba0ed492c40a
diff --git a/ui/litellm-dashboard/src/app/(dashboard)/hooks/onboarding/useOnboarding.test.ts b/ui/litellm-dashboard/src/app/(dashboard)/hooks/onboarding/useOnboarding.test.tsindex f5f63c0586e..50238b2a6f9 100644--- a/ui/litellm-dashboard/src/app/(dashboard)/hooks/onboarding/useOnboarding.test.ts+++ b/ui/litellm-dashboard/src/app/(dashboard)/hooks/onboarding/useOnboarding.test.ts@@ -21,7 +21,12 @@ describe("useOnboardingCredentials", () => {let queryClient: QueryClient;beforeEach(() => {- queryClient = new QueryClient({ defaultOptions: { queries: { retry: false } } });+ queryClient = new QueryClient({+ defaultOptions: {+ queries: { retry: false },+ mutations: { retry: false },+ },+ });vi.clearAllMocks();mockUseUIConfig.mockReturnValue({ isLoading: false });});@@ -77,7 +82,12 @@ describe("useClaimOnboardingToken", () => {let queryClient: QueryClient;beforeEach(() => {- queryClient = new QueryClient({ defaultOptions: { queries: { retry: false } } });+ queryClient = new QueryClient({+ defaultOptions: {+ queries: { retry: false },+ mutations: { retry: false },+ },+ });vi.clearAllMocks();mockUseUIConfig.mockReturnValue({ isLoading: false });});diff --git a/ui/litellm-dashboard/src/app/(dashboard)/hooks/onboarding/useOnboarding.ts b/ui/litellm-dashboard/src/app/(dashboard)/hooks/onboarding/useOnboarding.tsindex 554444f46c1..0e3a4d236fd 100644--- a/ui/litellm-dashboard/src/app/(dashboard)/hooks/onboarding/useOnboarding.ts+++ b/ui/litellm-dashboard/src/app/(dashboard)/hooks/onboarding/useOnboarding.ts@@ -5,11 +5,19 @@ import { createQueryKeys } from "../common/queryKeysFactory";const onboardingKeys = createQueryKeys("onboarding");+export interface OnboardingCredentials {+ token: string;+ login_url: string;+}+export const useOnboardingCredentials = (inviteId: string | null) => {const { isLoading: isUIConfigLoading } = useUIConfig();- return useQuery({+ return useQuery<OnboardingCredentials>({queryKey: onboardingKeys.detail(inviteId ?? ""),- queryFn: async () => await getOnboardingCredentials(inviteId!),+ queryFn: async () => {+ if (!inviteId) throw new Error("inviteId is required");+ return getOnboardingCredentials(inviteId);+ },enabled: Boolean(inviteId) && !isUIConfigLoading,});};