From eb31525283a738757bd51470a6553bea61d45849 Mon Sep 17 00:00:00 2001 From: Christian Owusu <36159205+crisshaker@users.noreply.github.com> Date: Thu, 24 Apr 2025 09:03:58 +0000 Subject: [PATCH 1/2] Improve duplicate team member error message --- ui/litellm-dashboard/src/components/networking.tsx | 7 ++++++- ui/litellm-dashboard/src/components/team/team_info.tsx | 8 +++++++- ui/litellm-dashboard/src/utils/errorUtils.ts | 6 ++++++ 3 files changed, 19 insertions(+), 2 deletions(-) create mode 100644 ui/litellm-dashboard/src/utils/errorUtils.ts diff --git a/ui/litellm-dashboard/src/components/networking.tsx b/ui/litellm-dashboard/src/components/networking.tsx index 63a4d6f101..6219fb9884 100644 --- a/ui/litellm-dashboard/src/components/networking.tsx +++ b/ui/litellm-dashboard/src/components/networking.tsx @@ -5,6 +5,7 @@ import { all_admin_roles } from "@/utils/roles"; import { message } from "antd"; import { TagNewRequest, TagUpdateRequest, TagDeleteRequest, TagInfoRequest, TagListResponse, TagInfoResponse } from "./tag_management/types"; import { Team } from "./key_team_helpers/key_list"; +import { UiError } from "@/utils/errorUtils"; const isLocal = process.env.NODE_ENV === "development"; export const proxyBaseUrl = isLocal ? "http://localhost:4000" : null; @@ -3263,7 +3264,11 @@ export const teamMemberAddCall = async ( const errorData = await response.text(); handleError(errorData); console.error("Error response from the server:", errorData); - throw new Error("Network response was not ok"); + debugger; + if (errorData.includes('already in team')) { + throw new UiError("User is already a member of this team") + } + throw new Error("Failed to add team member"); } const data = await response.json(); diff --git a/ui/litellm-dashboard/src/components/team/team_info.tsx b/ui/litellm-dashboard/src/components/team/team_info.tsx index 8cf18470cf..eccad53ba6 100644 --- a/ui/litellm-dashboard/src/components/team/team_info.tsx +++ b/ui/litellm-dashboard/src/components/team/team_info.tsx @@ -33,6 +33,7 @@ import MemberModal from "./edit_membership"; import UserSearchModal from "@/components/common_components/user_search_modal"; import { getModelDisplayName } from "../key_team_helpers/fetch_available_models_team_key"; import { isAdminRole } from "@/utils/roles"; +import { UiError } from "@/utils/errorUtils"; export interface TeamData { team_id: string; @@ -131,7 +132,12 @@ const TeamInfoView: React.FC = ({ form.resetFields(); fetchTeamInfo(); } catch (error) { - message.error("Failed to add team member"); + if (error instanceof UiError) { + message.error(error.message) + } else { + message.error("Failed to add team member"); + } + console.error("Error adding team member:", error); } }; diff --git a/ui/litellm-dashboard/src/utils/errorUtils.ts b/ui/litellm-dashboard/src/utils/errorUtils.ts new file mode 100644 index 0000000000..24c5cc8a41 --- /dev/null +++ b/ui/litellm-dashboard/src/utils/errorUtils.ts @@ -0,0 +1,6 @@ +export class UiError extends Error { + constructor(message: string) { + super(message); + Object.setPrototypeOf(this, UiError.prototype) + } +} \ No newline at end of file From ca4e1c8566b07f44cdced2a369b92d87d0c7f55c Mon Sep 17 00:00:00 2001 From: Christian Owusu <36159205+crisshaker@users.noreply.github.com> Date: Thu, 24 Apr 2025 09:05:51 +0000 Subject: [PATCH 2/2] Remove debugger --- ui/litellm-dashboard/src/components/networking.tsx | 1 - 1 file changed, 1 deletion(-) diff --git a/ui/litellm-dashboard/src/components/networking.tsx b/ui/litellm-dashboard/src/components/networking.tsx index 6219fb9884..20c44d26fa 100644 --- a/ui/litellm-dashboard/src/components/networking.tsx +++ b/ui/litellm-dashboard/src/components/networking.tsx @@ -3264,7 +3264,6 @@ export const teamMemberAddCall = async ( const errorData = await response.text(); handleError(errorData); console.error("Error response from the server:", errorData); - debugger; if (errorData.includes('already in team')) { throw new UiError("User is already a member of this team") }