Skip to content

fix(proxy): Enable partial matching for User ID filter in virtual keys page #12205

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

Conversation

colesmcintosh
Copy link
Collaborator

Title

fix(proxy): Enable partial matching for User ID filter in virtual keys page

Relevant issues

Fixes LIT-268

Pre-Submission checklist

  • I have Added testing in the tests/litellm/ directory, Adding at least 1 test is a hard requirement - see details
  • I have added a screenshot of my new test passing locally
  • My PR passes all unit tests on make test-unit
  • My PR's scope is as isolated as possible, it only solves 1 specific problem

Type

🐛 Bug Fix

Changes

Problem

The virtual key page (/ui/?page=api-keys) required users to enter the complete, exact User ID to filter results. Partial searches returned no results, making it difficult to find keys when users only remembered part of a User ID.

Solution

Updated the _list_key_helper function in key_management_endpoints.py to use Prisma's contains operator with case-insensitive mode for user_id filtering instead of exact matching.

Implementation Details

  • Changed user_id filter from exact match to partial substring match with case-insensitive mode
  • Updated the Prisma query condition to use {"contains": user_id, "mode": "insensitive"}
  • Added comprehensive test coverage in test_list_key_helper_user_id_partial_matching

Testing

Added tests to verify:

  1. Partial substring matching works correctly
  2. Case-insensitive matching works
  3. Exact matches still work
  4. Multiple results are returned for common substrings
  5. No results are returned for non-existent patterns

Test passing locally:

tests/proxy_admin_ui_tests/test_key_management.py::test_list_key_helper_user_id_partial_matching PASSED

colesmcintosh and others added 2 commits July 1, 2025 10:10
…s page

- Changed user_id filter from exact match to partial substring match with case-insensitive mode
- Updated _list_key_helper function to use Prisma's 'contains' operator with 'insensitive' mode
- Added comprehensive test coverage for partial matching functionality
- Fixes LIT-268: Virtual key page filter by User ID now supports partial matches instead of requiring exact match
Copy link

vercel bot commented Jul 1, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
litellm ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jul 1, 2025 5:00pm

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