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]

fix(projects): project dropdown empty for internal_user (3 bugs) (#26664)

ishaan-berri32704ff7b289
diff --git a/.github/workflows/check-lazy-openapi-snapshot.yml b/.github/workflows/check-lazy-openapi-snapshot.yml
deleted file mode 100644
index 2e4ed3637f1..00000000000
--- a/.github/workflows/check-lazy-openapi-snapshot.yml
+++ /dev/null
@@ -1,75 +0,0 @@
-name: Check Lazy OpenAPI Snapshot
-
-on:
- pull_request:
- branches:
- - main
- - litellm_internal_staging
- - "litellm_**"
-
-permissions:
- contents: read
- checks: write
-
-concurrency:
- group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
- cancel-in-progress: true
-
-jobs:
- verify:
- runs-on: ubuntu-latest
- timeout-minutes: 10
- steps:
- - uses: actions/checkout@08eba0b27e820071cde6df949e0beb9ba4906955 # v4.3.0
- with:
- persist-credentials: false
-
- - name: Set up Python
- uses: actions/setup-python@a26af69be951a213d495a4c3e4e4022e16d87065 # v5.6.0
- with:
- python-version: "3.12"
-
- - name: Set up uv
- uses: astral-sh/setup-uv@37802adc94f370d6bfd71619e3f0bf239e1f3b78 # v7
- with:
- version: "0.10.9"
-
- - name: Cache uv dependencies
- uses: actions/cache@0057852bfaa89a56745cba8c7296529d2fc39830 # v4.3.0
- with:
- path: |
- ~/.cache/uv
- .venv
- key: ${{ runner.os }}-uv-${{ hashFiles('uv.lock') }}
- restore-keys: |
- ${{ runner.os }}-uv-
-
- - name: Install dependencies
- run: uv sync --frozen --all-groups --all-extras
-
- - name: Regenerate snapshot to /tmp
- id: regen
- run: |
- cp litellm/proxy/_lazy_openapi_snapshot.json /tmp/snapshot.committed.json
- uv run --no-sync python -m litellm.proxy._lazy_openapi_snapshot
- mv litellm/proxy/_lazy_openapi_snapshot.json /tmp/snapshot.fresh.json
- mv /tmp/snapshot.committed.json litellm/proxy/_lazy_openapi_snapshot.json
-
- - name: Compare
- id: diff
- continue-on-error: true
- run: |
- diff -q /tmp/snapshot.fresh.json litellm/proxy/_lazy_openapi_snapshot.json
-
- - name: Mark neutral if drift
- if: steps.diff.outcome == 'failure'
- uses: LouisBrunner/checks-action@6b626ffbad7cc56fd58627f774b9067e6118af23 # v2.0.0
- with:
- token: ${{ secrets.GITHUB_TOKEN }}
- name: lazy-openapi-snapshot
- conclusion: neutral
- output: |
- {
- "title": "Lazy openapi snapshot is stale",
- "summary": "Run `python -m litellm.proxy._lazy_openapi_snapshot` and commit the regenerated `litellm/proxy/_lazy_openapi_snapshot.json`. Not blocking — the snapshot will regenerate at release if not committed."
- }
diff --git a/enterprise/litellm_enterprise/proxy/management_endpoints/project_endpoints.py b/enterprise/litellm_enterprise/proxy/management_endpoints/project_endpoints.py
index f6ed7767c46..4bfe9d31874 100644
--- a/enterprise/litellm_enterprise/proxy/management_endpoints/project_endpoints.py
+++ b/enterprise/litellm_enterprise/proxy/management_endpoints/project_endpoints.py
@@ -857,10 +857,16 @@ async def project_info(
where={"team_id": project.team_id}
)
if team:
- is_team_member = (
- user_api_key_dict.user_id in team.admins
- or user_api_key_dict.user_id in team.members
- )
+ caller_user_id = user_api_key_dict.user_id
+ for m in team.members_with_roles or []:
+ m_user_id = (
+ m.get("user_id")
+ if isinstance(m, dict)
+ else getattr(m, "user_id", None)
+ )
+ if m_user_id == caller_user_id:
+ is_team_member = True
+ break
if not (is_admin or is_team_member):
raise HTTPException(
@@ -911,20 +917,20 @@ async def list_projects(
include={"litellm_budget_table": True, "object_permission": True}
)
else:
- # Get projects for teams the user belongs to
- user_teams = await prisma_client.db.litellm_teamtable.find_many(
- where={
- "OR": [
- {"members": {"has": user_api_key_dict.user_id}},
- {"admins": {"has": user_api_key_dict.user_id}},
- ]
- }
+ # Look up the user's team memberships via the reverse-index on
+ # LiteLLM_UserTable.teams (maintained by team_member_add alongside
+ # members_with_roles). This avoids a full scan of all team rows.
+ user_record = await prisma_client.db.litellm_usertable.find_unique(
+ where={"user_id": user_api_key_dict.user_id},
+ )
+ user_team_ids = (
+ user_record.teams
+ if user_record is not None and user_record.teams
+ else []
)
-
- team_ids = [team.team_id for team in user_teams]
projects = await prisma_client.db.litellm_projecttable.find_many(
- where={"team_id": {"in": team_ids}},
+ where={"team_id": {"in": user_team_ids}},
include={"litellm_budget_table": True, "object_permission": True},
)
diff --git a/litellm/proxy/_types.py b/litellm/proxy/_types.py
index 85320996911..8520e03f834 100644
--- a/litellm/proxy/_types.py
+++ b/litellm/proxy/_types.py
@@ -668,6 +668,8 @@ class LiteLLMRoutes(enum.Enum):
"/models/{model_id}",
"/guardrails/list",
"/v2/guardrails/list",
+ "/project/list",
+ "/project/info",
]
+ spend_tracking_routes
+ key_management_routes
@@ -692,6 +694,9 @@ class LiteLLMRoutes(enum.Enum):
"/model/{model_id}/update",
"/prompt/list",
"/prompt/info",
+ # Project read routes - endpoint scopes results to caller's teams (non-admin)
+ "/project/list",
+ "/project/info",
# Invitation routes - org/team admins checked in endpoint via _user_has_admin_privileges
"/invitation/new",
"/invitation/delete",
diff --git a/ui/litellm-dashboard/src/app/(dashboard)/hooks/projects/useProjects.ts b/ui/litellm-dashboard/src/app/(dashboard)/hooks/projects/useProjects.ts
index 85c8b25645c..79976f54626 100644
--- a/ui/litellm-dashboard/src/app/(dashboard)/hooks/projects/useProjects.ts
+++ b/ui/litellm-dashboard/src/app/(dashboard)/hooks/projects/useProjects.ts
@@ -6,8 +6,8 @@ import {
deriveErrorMessage,
handleError,
} from "@/components/networking";
-import { all_admin_roles } from "@/utils/roles";
import useAuthorized from "@/app/(dashboard)/hooks/useAuthorized";
+import { all_admin_roles } from "@/utils/roles";
// ── Types ────────────────────────────────────────────────────────────────────
@@ -81,7 +81,6 @@ export const useProjects = () => {
return useQuery<ProjectResponse[]>({
queryKey: projectKeys.list({}),
queryFn: async () => fetchProjects(accessToken!),
- enabled:
- Boolean(accessToken) && all_admin_roles.includes(userRole || ""),
+ enabled: Boolean(accessToken) && all_admin_roles.includes(userRole!),
});
};
diff --git a/ui/litellm-dashboard/src/components/UsagePage/components/UsagePageView.tsx b/ui/litellm-dashboard/src/components/UsagePage/components/UsagePageView.tsx
index 69b29564d83..809f1d4e17b 100644
--- a/ui/litellm-dashboard/src/components/UsagePage/components/UsagePageView.tsx
+++ b/ui/litellm-dashboard/src/components/UsagePage/components/UsagePageView.tsx
@@ -169,8 +169,8 @@ const UsagePage: React.FC<UsagePageProps> = ({ teams, organizations }) => {
}
}, [isAdmin, userID]);
- // For non-admins, always pass their own user_id
- const effectiveUserId = isAdmin ? selectedUserId : userID || null;
+ // For non-admins or "my-usage" view, always pass their own user_id
+ const effectiveUserId = usageView === "my-usage" || !isAdmin ? userID || null : selectedUserId;
const startTime = useMemo(() => (dateValue.from ? new Date(dateValue.from) : null), [dateValue.from]);
const endTime = useMemo(() => (dateValue.to ? new Date(dateValue.to) : null), [dateValue.to]);
@@ -477,10 +477,10 @@ const UsagePage: React.FC<UsagePageProps> = ({ teams, organizations }) => {
}
/>
)}
- {/* Your Usage Panel */}
- {usageView === "global" && (
+ {/* Your Usage / Global Usage Panel */}
+ {(usageView === "global" || usageView === "my-usage") && (
<>
- {isAdmin && (
+ {isAdmin && usageView === "global" && (
<div className="mb-4">
<Text className="mb-2">Filter by user</Text>
<Select
diff --git a/ui/litellm-dashboard/src/components/UsagePage/components/UsageViewSelect/UsageViewSelect.tsx b/ui/litellm-dashboard/src/components/UsagePage/components/UsageViewSelect/UsageViewSelect.tsx
index 53236756d5c..11fdb8a7cf5 100644
--- a/ui/litellm-dashboard/src/components/UsagePage/components/UsageViewSelect/UsageViewSelect.tsx
+++ b/ui/litellm-dashboard/src/components/UsagePage/components/UsageViewSelect/UsageViewSelect.tsx
@@ -11,7 +11,7 @@ import {
} from "@ant-design/icons";
import { Badge, Select } from "antd";
import React from "react";
-export type UsageOption = "global" | "organization" | "team" | "customer" | "tag" | "agent" | "user" | "user-agent-activity";
+export type UsageOption = "global" | "my-usage" | "organization" | "team" | "customer" | "tag" | "agent" | "user" | "user-agent-activity";
export interface UsageViewSelectProps {
value: UsageOption;
onChange: (value: UsageOption) => void;
@@ -43,6 +43,13 @@ const OPTIONS: OptionConfig[] = [
descriptionForNonAdmin: "View your usage",
icon: <GlobalOutlined style={{ fontSize: "16px" }} />,
},
+ {
+ value: "my-usage",
+ label: "Your Usage",
+ description: "View your own usage",
+ icon: <UserOutlined style={{ fontSize: "16px" }} />,
+ adminOnly: true,
+ },
{
value: "organization",
label: "Organization Usage",