Skip to content

Improve duplicate team member error message #10267

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

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion ui/litellm-dashboard/src/components/networking.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -3263,7 +3264,10 @@ 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");
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();
Expand Down
8 changes: 7 additions & 1 deletion ui/litellm-dashboard/src/components/team/team_info.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -131,7 +132,12 @@ const TeamInfoView: React.FC<TeamInfoProps> = ({
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);
}
};
Expand Down
6 changes: 6 additions & 0 deletions ui/litellm-dashboard/src/utils/errorUtils.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
export class UiError extends Error {
constructor(message: string) {
super(message);
Object.setPrototypeOf(this, UiError.prototype)
}
}
Loading