Skip to content

fix: replace raw SQL with Prisma calls in admin user info endpoint#23230

Draft
CAFxX wants to merge 1 commit intoBerriAI:mainfrom
CAFxX:fix/replace-raw-sql-user-info-admin
Draft

fix: replace raw SQL with Prisma calls in admin user info endpoint#23230
CAFxX wants to merge 1 commit intoBerriAI:mainfrom
CAFxX:fix/replace-raw-sql-user-info-admin

Conversation

@CAFxX
Copy link
Contributor

@CAFxX CAFxX commented Mar 10, 2026

Summary

  • Replace raw SQL json_agg query in _get_user_info_for_proxy_admin with two concurrent Prisma find_many calls via asyncio.gather
  • The old query serialized entire LiteLLM_TeamTable and LiteLLM_VerificationToken tables into JSON blobs server-side, taking 15s+ on large deployments
  • Prisma calls avoid the json_agg overhead, return typed objects directly (no manual dict-to-model casting), and follow the project's no-raw-SQL guideline
  • Same response shape — no UI changes needed

Related: #23196 (DB performance guidelines), #23136, #23152

Test plan

  • Added test_get_user_info_for_proxy_admin_uses_prisma verifying:
    • Prisma find_many is called (not query_raw)
    • Teams and keys are returned with correct shape
    • Team alias is resolved on keys
    • litellm-dashboard keys are filtered out

🤖 Generated with Claude Code

The admin dashboard's /user/info endpoint used raw SQL with json_agg to
fetch all teams and keys in a single query. On large tables this takes
15s+ because PostgreSQL must serialize entire tables into JSON blobs.

Replace with two concurrent Prisma find_many calls via asyncio.gather,
which avoids json_agg overhead and follows the project's no-raw-SQL
guideline.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@vercel
Copy link

vercel bot commented Mar 10, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
litellm Error Error Mar 10, 2026 4:14am

Request Review

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant