Repository navigation
feat(proxy): let each app decide whether it may create unknown customers - #52485
Conversation
Let administrators choose Teams, Projects, or Virtual Keys as the gateway-wide app scope and assign customer budgets from existing budget groups. Includes the shared budget-group integration from PR #52411 and builds on the existing app accounting implementation.
Use the existing dashboard controls and compact budget rows. Add app filtering to customer usage and retain trusted app context for budget rejections. Update request-header handling, tracing registry coverage, bounded app discovery, and optional caller-metadata tests.
Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
|
I'll fix CI failures and address comments from users with write access. I'll skip comments containing "(aside)".
|
…mber Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
|
@greptileai please review the current upsert-rule changes for correctness and authorization regressions. The configured checks on this stacked PR are passing. |
|
bugbot run Please review the current upsert-rule changes for incorrect customer creation, authorization gaps, and regressions in requests using existing customers. |
[Medium impact] The UI extraction appears safe to merge.
|
…ion's budget Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
|
@greptileai please review the latest upsert-rule fix at 6ee9e15, including the unknown-customer refusal before budget checks. Configured CI checks pass. |
|
bugbot run Please verify the unknown-customer refusal fix at 6ee9e15 and review the current changes for remaining correctness issues. |
Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
Let administrators choose Teams, Projects, or Virtual Keys as the gateway-wide app scope and assign customer budgets from existing budget groups. Includes the shared budget-group integration from PR #52411 and builds on the existing app accounting implementation.
Use the existing dashboard controls and compact budget rows. Add app filtering to customer usage and retain trusted app context for budget rejections. Update request-header handling, tracing registry coverage, bounded app discovery, and optional caller-metadata tests.
Enforce an authenticated app budget when optional customer and app headers are omitted. Normalize overlapping scalar and explicit budget windows to a single charge with the stricter cap and explicit reset time. Cover all app primitives through native HTTP auth and use realistic empty gateway configuration in existing test doubles.
|
@greptileai please review the remaining UI settings extraction at c5a73f6. The prior backend fixes were reviewed and configured CI checks pass. |
|
bugbot run Please review the remaining UI settings extraction at c5a73f6 for regressions. The prior backend fixes were reviewed and configured CI checks pass. |
There was a problem hiding this comment.
✅ Bugbot reviewed your changes and found no new issues!
Comment @cursor review or bugbot run to trigger another review on this PR
Reviewed by Cursor Bugbot for commit c5a73f6. Configure here.
9706a91 to
677b9f1
Compare
…omer_provisioning Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
|
|
Use shared customer budget controls for app forms and resolve member budgets at one owner. Remove unused app lifecycle and listing routes. Parse request identity once, check each global and app scope once, and keep app counters alive through the existing database flush window.
Persist the original trusted customer and app billing context on managed jobs. Restore it in batch and background cost polling with the original request time, preserving admission windows and existing claim behavior. Recognize the India Bedrock model prefix in dashboard model setup.
…omer_provisioning Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
Set the required migration lock timeout and add the billing-context column only if it is absent. Use per-request completion test callbacks and await the MCP panel failure notification. Keep response, pricing, and complete callback-sequence assertions.
Use the upstream country-prefix handling to clear the model-setup merge conflict.
…' into litellm_app_customer_provisioning
Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
…ne helper Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
Merging this PR will not alter performance1 warning
Comparing |
Handwritten 1-3 sentence description
Let admins define upsert rules per app on customer portal
Details
Link to Devin session: https://app.devin.ai/sessions/df57dd6feb764cd684428371c02d408b
Open in Devin Desktop: https://app.devin.ai/desktop/session/df57dd6feb764cd684428371c02d408b?variant=devin
Requested by: @moe-berri
Built on #52477, which adds the app model and is now on
main.TLDR
Problem this solves:
How it solves it:
User Flow
Before: an admin wants only one app to onboard new tenants, but every app's first request for a new tenant creates it
searchteam key sends POST https://litellm-domain/v1/chat/completions withx-litellm-customer-org-alias: new-tenantnew-tenantnow exists as a customer organizationAfter: the admin turns the switch off for that app, and it can no longer create tenants
search, unchecks "This app may create new customers" and savesx-litellm-customer-org-alias: new-tenantUnknown customer in x-litellm-customer-org-alias. App search may not create customers., and no organization is createdcoworkerapp still creates new tenantsPre-Submission checklist
Screenshots / Proof of Fix
Real Postgres, one dedicated Redis on port 56379 for router and coordination state, 2 proxy workers on each proxy (two
Started server processPIDs each), and realanthropic/claude-haiku-4-5calls. The app definition is Teams, with teamscoworkerandsearchconfigured as apps, and one key with no team.Env var names:
DATABASE_URL,LITELLM_MASTER_KEY,ANTHROPIC_API_KEY.config.yamlis a copy oflitellm/proxy/dev_config.yamlwithrouter_settings.redis_host/redis_portandgeneral_settings.coordination_redis.host/portset to127.0.0.1and56379.Before (6915477)
searchkey with an unknown tenant and member returns 200. There is no switch to turn offorganization_rows 1,member_rows 1After (72ef154)
App switch
coworkerkey with a new tenant and member returns 200, and the count is 1 organization and 1 membersearchswitched off in the UI. Thesearchkey with an unknown tenant returns 403, and the count is 0 and 0searchkey with a known tenant and known member returns 200searchkey with a known tenant and an unknown member returns 403, and no member row is createdcoworkerkey with another new tenant still returns 200 and creates itRequests with no app
Requests that belong to no app may not create customers., and no row is created{"resource_type": "team"}without the switch keeps it off, and the definition stays TeamsTwo workers
A change saved through one worker applied to the first request served by the other worker, between 0.04s and 0.67s after the save.
The 32 commands and their full output are in the collapsed block.
Case list from the run log
Commits after 72ef154 only rename the app checkbox label and disable it while a save is pending, so the request behavior proven above is unchanged.
AppsManager.integration.test.tsxcovers both.Tests
Type
🆕 New Feature
Caveats (if any)
Severe
ADD COLUMN IF NOT EXISTS ... NOT NULL DEFAULT true, no row rewriteMedium
Low
Final Attestation
Note
Medium Risk
Touches the auth and customer-hierarchy path and changes when new tenants may be created, but defaults keep prior behavior and refusal is explicit 403 instead of silent failure.
Overview
Adds per-app and gateway-level controls for whether requests may auto-register unknown customer organizations or members. Each app gets
auto_create_customers(DB column, default true); gateway definition gainsauto_create_customers_without_appfor keys that map to no app.During API key auth, customer hierarchy resolution uses gated registrars that skip creation when policy forbids it, and
refuse_unknown_customerreturns 403 with a message naming the offending header when the request references a customer the hierarchy could not resolve. Known customers still work when the switch is off.AppStore and management types persist both settings; the dashboard exposes checkboxes on app settings and the app-definition page. A boot migration adds the app-table column with default true.
Reviewed by Cursor Bugbot for commit c5a73f6. Bugbot is set up for automated code reviews on this repo. Configure here.