Skip to content

fix(license): let a wildcard allowed_features license grant the auto_router feature - #41684

Merged
mateo-berri merged 1 commit into
mainfrom
litellm_wildcard_license_auto_router
Sep 17, 2026
Merged

mateo-berri merged 1 commit into
mainfrom
litellm_wildcard_license_auto_router

Conversation

@devin-ai-integration

@devin-ai-integration devin-ai-integration Bot commented Sep 17, 2026 •

Copy link
Copy Markdown
Contributor

TLDR

Problem this solves:

  • Enterprise licenses default to allowed_features: ["*"], meaning every feature
  • The v1.101.0 auto-router gate only accepts the literal auto_router entry
  • A wildcard license keeps the one-router-per-capability limit
  • Two custom auto-routers in config.yaml then abort startup with a ValueError

How it solves it:

  • LicenseCheck.grants_feature treats a * entry as granting every feature
  • auto_router_capability_limit goes through it, so ["*"] lifts the limit
  • Regression tests cover the wildcard on raw payloads and signed licenses

User Flow

Before: an enterprise operator upgrading to v1.101.0 with two custom auto-routers cannot start the proxy at all, even though their license covers every feature

  1. They set LITELLM_LICENSE to their enterprise key, whose decoded payload reads "allowed_features": ["*"], and keep a config.yaml with two auto_router/complexity_router deployments that each define their own tier_definitions
  2. They start the v1.101.0 proxy (litellm --config config.yaml)
  3. Startup aborts with ValueError: config.yaml model_list: At most 1 auto-router(s) with operator-defined tier_definitions or an operator-written classifier prompt can be registered but this would make 2. ... A LiteLLM license with the 'auto_router' feature lifts the limit. and the process exits
  4. GET http://litellm-domain/health/liveliness gets no answer: the connection fails or times out because no worker ever starts serving

After: the same operator starts the proxy and both routers serve traffic

  1. They set LITELLM_LICENSE to the same enterprise key ("allowed_features": ["*"]) and keep the same config.yaml with two custom auto-routers
  2. They start the proxy with this fix (litellm --config config.yaml)
  3. The proxy boots and GET http://litellm-domain/health/liveliness returns "I'm alive!"
  4. GET http://litellm-domain/health/license returns 200 with "allowed_features": ["*"]
  5. POST http://litellm-domain/v1/chat/completions with "model": "support-router" and again with "model": "engineering-router" each return 200 with a real completion

Relevant issues

Affected release

regression in v1.101.0 (first in v1.101.0-rc.1, from #39674 on top of #39468; v1.100.x is not affected)

Linear ticket

Resolves LIT-8019

Pre-Submission checklist

Please complete all items before asking a LiteLLM maintainer to review your PR

  • I have added meaningful tests
  • The handful of test files covering my change pass locally, e.g. uv run pytest tests/test_litellm/<your_test_file>.py -v. Leave the suites (make test-unit-*, make test-unit) to CI: it finishes in ~15 minutes where a laptop takes an hour or more
  • My PR passes all required CI/CD checks (e.g., lint, schema.d.ts sync check, etc.)
  • My PR's scope is as isolated as possible; it only solves 1 specific problem
  • I have received a Greptile Confidence Score of at least 4/5 before requesting a maintainer review (Greptile reviews automatically once the PR is opened; only comment @greptileai to re-request a review after pushing changes)

Delays in PR merge?

If you're seeing a delay in your PR being merged, ping the LiteLLM Team on Slack (#pr-review).

Screenshots / Proof of Fix

Every leg is a live proxy booted from a detached worktree at the named commit with its own venv and 2 uvicorn workers on a random free port. The config.yaml legs run with no database; the notes at the end cover the database write path. The license is read from the LITELLM_LICENSE env var by each worker on its own, so there is no state shared between workers to cross-check, and each chat request is sent twice. The routers call OpenAI for real (gpt-5.4-mini classifies and answers the easy tier, gpt-5.6 the hard one). The three license keys are offline-signed test keys that differ only in allowed_features; their payloads carry max_users: 100, max_teams: 5, and an expiry of 2027-07-06. Chat responses are trimmed with jq to the model, the content, and the token count

config.yaml, the same file on every leg:

model_list:
  - model_name: gpt-5.4-mini
    litellm_params:
      model: openai/gpt-5.4-mini
      api_key: os.environ/OPENAI_API_KEY
  - model_name: gpt-5.6
    litellm_params:
      model: openai/gpt-5.6
      api_key: os.environ/OPENAI_API_KEY
  - model_name: support-router
    litellm_params:
      model: auto_router/complexity_router
      complexity_router_config:
        classifier_type: llm
        classifier_llm_config:
          model: gpt-5.4-mini
        tier_definitions:
          - name: routine
            description: short factual answers and routine drafting
          - name: hard
            description: multi-step reasoning or analysis
        tiers:
          routine: gpt-5.4-mini
          hard: gpt-5.6
        fallback_tier: routine
  - model_name: engineering-router
    litellm_params:
      model: auto_router/complexity_router
      complexity_router_config:
        classifier_type: llm
        classifier_llm_config:
          model: gpt-5.4-mini
        tier_definitions:
          - name: quick
            description: one-line code questions and lookups
          - name: deep
            description: architecture, debugging across files, or proofs
        tiers:
          quick: gpt-5.4-mini
          deep: gpt-5.6
        fallback_tier: quick

general_settings:
  master_key: sk-1234

The customer's config trips the limit that #39674 added on top of the auto_router feature check from #39468, and both first shipped in v1.101.0-rc.1. The wildcard license across that regression, each row a separate live proxy:

Checkpoint Proxy commit Expected Boot support-router engineering-router
Before #39674 74ebe29 boots boots 200 + 200 200 + 200
After #39674 d0d09e5 blocked blocked, ValueError no answer no answer
Before this PR 1dd4c13 blocked blocked, ValueError no answer no answer
After this PR c2fbb11 boots boots 200 + 200 200 + 200

Before (1dd4c13)

Wildcard license ("allowed_features": ["*"])

  1. Start the proxy; startup aborts in every worker and nothing ever serves

    export LITELLM_LICENSE="$(cat license_wildcard.txt)"
    litellm --config config.yaml --port 51309 --num_workers 2
    ValueError: config.yaml model_list: At most 1 auto-router(s) with operator-defined tier_definitions or an operator-written classifier prompt can be registered but this would make 2. Use the shipped tiers and classifier prompt for this router or remove an existing router with tier_definitions or its own classifier prompt. A LiteLLM license with the 'auto_router' feature lifts the limit.
    ERROR:    Application startup failed. Exiting.
    
  2. GET /health/liveliness gets no answer

    $ curl -sS -m 5 http://localhost:51309/health/liveliness
    curl: (28) Connection timed out after 5010 milliseconds
    

License naming the feature ("allowed_features": ["auto_router"])

  1. Start the proxy; both workers come up and it serves traffic

    export LITELLM_LICENSE="$(cat license_control_auto_router.txt)"
    litellm --config config.yaml --port 40821 --num_workers 2
    
  2. GET /health/liveliness returns 200

    $ curl -s http://localhost:40821/health/liveliness -w '\nHTTP %{http_code}\n'
    "I'm alive!"
    HTTP 200
    
  3. GET /health/license returns 200

    $ curl -s http://localhost:40821/health/license -H 'Authorization: Bearer sk-1234' -w '\nHTTP %{http_code}\n'
    {"has_license":true,"license_type":"enterprise","expiration_date":"2027-07-06","allowed_features":["auto_router"],"limits":{"max_users":100,"max_teams":5}}
    HTTP 200
    
  4. POST /v1/chat/completions with "model": "support-router", sent twice; both return 200 with a real completion

    $ curl -s -o out.json -w 'HTTP %{http_code}\n' http://localhost:40821/v1/chat/completions -H 'Authorization: Bearer sk-1234' -H 'Content-Type: application/json' -d '{"model":"support-router","messages":[{"role":"user","content":"What year did the first moon landing happen? One line."}]}'; jq -c '{model, content: .choices[0].message.content, total_tokens: .usage.total_tokens}' out.json
    HTTP 200
    {"model":"support-router","content":"1969","total_tokens":23}
    $ (same request again)
    HTTP 200
    {"model":"support-router","content":"The first moon landing happened in **1969**.","total_tokens":32}
    
  5. POST /v1/chat/completions with "model": "engineering-router", sent twice; both return 200 with a real completion

    $ curl -s -o out.json -w 'HTTP %{http_code}\n' http://localhost:40821/v1/chat/completions -H 'Authorization: Bearer sk-1234' -H 'Content-Type: application/json' -d '{"model":"engineering-router","messages":[{"role":"user","content":"In Python, what does dict.setdefault do? One line."}]}'; jq -c '{model, content: .choices[0].message.content, total_tokens: .usage.total_tokens}' out.json
    HTTP 200
    {"model":"engineering-router","content":"`dict.setdefault(key, default)` returns the value for `key` if it exists; otherwise it inserts `key` with `default` and returns `default`.","total_tokens":54}
    $ (same request again)
    HTTP 200
    {"model":"engineering-router","content":"`dict.setdefault(key, default)` returns `dict[key]` if the key exists; otherwise it inserts `key` with `default` and returns that default.","total_tokens":54}
    

License with other features only ("allowed_features": ["sso", "audit_logs"])

  1. Start the proxy; startup aborts in every worker and nothing ever serves

    export LITELLM_LICENSE="$(cat license_other_features.txt)"
    litellm --config config.yaml --port 45872 --num_workers 2
    ValueError: config.yaml model_list: At most 1 auto-router(s) with operator-defined tier_definitions or an operator-written classifier prompt can be registered but this would make 2. Use the shipped tiers and classifier prompt for this router or remove an existing router with tier_definitions or its own classifier prompt. A LiteLLM license with the 'auto_router' feature lifts the limit.
    ERROR:    Application startup failed. Exiting.
    
  2. GET /health/liveliness gets no answer

    $ curl -sS -m 5 http://localhost:45872/health/liveliness
    curl: (7) Failed to connect to localhost port 45872 after 4027 ms: Couldn't connect to server
    

After (c2fbb11)

Wildcard license ("allowed_features": ["*"])

  1. Start the proxy; both workers come up and it serves traffic

    export LITELLM_LICENSE="$(cat license_wildcard.txt)"
    litellm --config config.yaml --port 30935 --num_workers 2
    
  2. GET /health/liveliness returns 200

    $ curl -s http://localhost:30935/health/liveliness -w '\nHTTP %{http_code}\n'
    "I'm alive!"
    HTTP 200
    
  3. GET /health/license returns 200

    $ curl -s http://localhost:30935/health/license -H 'Authorization: Bearer sk-1234' -w '\nHTTP %{http_code}\n'
    {"has_license":true,"license_type":"enterprise","expiration_date":"2027-07-06","allowed_features":["*"],"limits":{"max_users":100,"max_teams":5}}
    HTTP 200
    
  4. POST /v1/chat/completions with "model": "support-router", sent twice; both return 200 with a real completion

    $ curl -s -o out.json -w 'HTTP %{http_code}\n' http://localhost:30935/v1/chat/completions -H 'Authorization: Bearer sk-1234' -H 'Content-Type: application/json' -d '{"model":"support-router","messages":[{"role":"user","content":"What year did the first moon landing happen? One line."}]}'; jq -c '{model, content: .choices[0].message.content, total_tokens: .usage.total_tokens}' out.json
    HTTP 200
    {"model":"support-router","content":"1969.","total_tokens":24}
    $ (same request again)
    HTTP 200
    {"model":"support-router","content":"1969","total_tokens":23}
    
  5. POST /v1/chat/completions with "model": "engineering-router", sent twice; both return 200 with a real completion

    $ curl -s -o out.json -w 'HTTP %{http_code}\n' http://localhost:30935/v1/chat/completions -H 'Authorization: Bearer sk-1234' -H 'Content-Type: application/json' -d '{"model":"engineering-router","messages":[{"role":"user","content":"In Python, what does dict.setdefault do? One line."}]}'; jq -c '{model, content: .choices[0].message.content, total_tokens: .usage.total_tokens}' out.json
    HTTP 200
    {"model":"engineering-router","content":"`dict.setdefault(key, default)` returns the value for `key` if it exists; otherwise it inserts `key` with `default` and returns `default`.","total_tokens":54}
    $ (same request again)
    HTTP 200
    {"model":"engineering-router","content":"`dict.setdefault(key, default)` returns the value for `key` if it exists; otherwise it inserts `key` with `default` and returns `default`.","total_tokens":54}
    

License naming the feature ("allowed_features": ["auto_router"])

  1. Start the proxy; both workers come up and it serves traffic

    export LITELLM_LICENSE="$(cat license_control_auto_router.txt)"
    litellm --config config.yaml --port 49304 --num_workers 2
    
  2. GET /health/liveliness returns 200

    $ curl -s http://localhost:49304/health/liveliness -w '\nHTTP %{http_code}\n'
    "I'm alive!"
    HTTP 200
    
  3. GET /health/license returns 200

    $ curl -s http://localhost:49304/health/license -H 'Authorization: Bearer sk-1234' -w '\nHTTP %{http_code}\n'
    {"has_license":true,"license_type":"enterprise","expiration_date":"2027-07-06","allowed_features":["auto_router"],"limits":{"max_users":100,"max_teams":5}}
    HTTP 200
    
  4. POST /v1/chat/completions with "model": "support-router", sent twice; both return 200 with a real completion

    $ curl -s -o out.json -w 'HTTP %{http_code}\n' http://localhost:49304/v1/chat/completions -H 'Authorization: Bearer sk-1234' -H 'Content-Type: application/json' -d '{"model":"support-router","messages":[{"role":"user","content":"What year did the first moon landing happen? One line."}]}'; jq -c '{model, content: .choices[0].message.content, total_tokens: .usage.total_tokens}' out.json
    HTTP 200
    {"model":"support-router","content":"1969.","total_tokens":24}
    $ (same request again)
    HTTP 200
    {"model":"support-router","content":"1969.","total_tokens":24}
    
  5. POST /v1/chat/completions with "model": "engineering-router", sent twice; both return 200 with a real completion

    $ curl -s -o out.json -w 'HTTP %{http_code}\n' http://localhost:49304/v1/chat/completions -H 'Authorization: Bearer sk-1234' -H 'Content-Type: application/json' -d '{"model":"engineering-router","messages":[{"role":"user","content":"In Python, what does dict.setdefault do? One line."}]}'; jq -c '{model, content: .choices[0].message.content, total_tokens: .usage.total_tokens}' out.json
    HTTP 200
    {"model":"engineering-router","content":"`dict.setdefault(key, default)` returns the value for `key` if it exists; otherwise it inserts `key` with `default` and returns `default`.","total_tokens":54}
    $ (same request again)
    HTTP 200
    {"model":"engineering-router","content":"`dict.setdefault(key, default)` returns the value for `key` if it exists; otherwise it inserts `key` with `default` and returns `default`.","total_tokens":54}
    

License with other features only ("allowed_features": ["sso", "audit_logs"])

  1. Start the proxy; startup aborts in every worker and nothing ever serves

    export LITELLM_LICENSE="$(cat license_other_features.txt)"
    litellm --config config.yaml --port 25177 --num_workers 2
    ValueError: config.yaml model_list: At most 1 auto-router(s) with operator-defined tier_definitions or an operator-written classifier prompt can be registered but this would make 2. Use the shipped tiers and classifier prompt for this router or remove an existing router with tier_definitions or its own classifier prompt. A LiteLLM license with the 'auto_router' feature lifts the limit.
    ERROR:    Application startup failed. Exiting.
    
  2. GET /health/liveliness gets no answer

    $ curl -sS -m 5 http://localhost:25177/health/liveliness
    curl: (28) Connection timed out after 5005 milliseconds
    

Notes from the run:

  • A blocked boot leaves the port unanswered; this PR leaves that alone
  • /health/license shows ["*"] verbatim on every leg; unchanged here
  • A license naming other features stays limited after the fix

The same gate guards POST /model/new, so both sides were also booted with their own Postgres (store_model_in_db: true, 2 workers, wildcard license unless stated) and the two routers were posted instead of read from config.yaml:

  • Second router via POST /model/new: 403 before, 200 after
  • Pre-fix boot drops a DB-stored second router; fixed here
  • Other-feature license: second router still 403 after the fix
  • /v1/models lists a new router after ~35s; pre-existing, unchanged
  • Same results on the tip merged into main at 29a959b

Type

🐛 Bug Fix

Caveats (if any)

Low

Final Attestation

  • The tests check the right things, including the edge cases, and regressions in the respective real-world customer use-cases are not possible after this PR

Note

Low Risk
Narrow license-gating fix for airgapped signed payloads; API-verified licenses without feature lists behave unchanged, and only expands entitlement for licenses that already include *.

Overview
Fixes a v1.101.0 regression where enterprise licenses with allowed_features: ["*"] did not lift the auto-router customization cap, so proxies with multiple custom auto-routers failed startup even though the license grants all features.

Adds LICENSE_ALL_FEATURES ("*") and LicenseCheck.grants_feature, which treats a * entry in allowed_features (list or bare string) as granting any named feature. auto_router_capability_limit now delegates to grants_feature("auto_router") instead of checking only for the literal auto_router string.

Tests cover wildcard list/scalar payloads, signed licenses with ["*"], and licenses that name other features without auto_router or *.

Reviewed by Cursor Bugbot for commit c2fbb11. Bugbot is set up for automated code reviews on this repo. Configure here.

@devin-ai-integration

devin-ai-integration Bot commented Sep 17, 2026 •

Copy link
Copy Markdown
Contributor Author

🤖 Devin AI Engineer

I'll be helping with this pull request! Here's what you should know:

✅ I will automatically:

  • Address comments on this PR. Add '(aside)' to your comment to have me ignore it.
  • Look at CI failures and help fix them

Note: I can only respond to comments from users who have write access to this repository.

⚙️ Control Options:

  • Disable automatic comment, CI, and merge conflict monitoring

@mateo-berri mateo-berri added backport-stable P0 regression fix only (Urgent ticket): cherry-pick onto the baking rc line before the stable tag run-ci labels Sep 17, 2026
@codspeed

codspeed Bot commented Sep 17, 2026

Copy link
Copy Markdown
Contributor

Merging this PR will not alter performance

✅ 31 untouched benchmarks


Comparing litellm_wildcard_license_auto_router (c2fbb11) with main (356b8d4)

Open in CodSpeed

@greptile-apps

greptile-apps Bot commented Sep 17, 2026

Copy link
Copy Markdown
Contributor

RetriggerConfidence Score: 5/5

The PR appears safe to merge, with the intended wildcard entitlement behavior covered through the production verification path

Summary

This PR makes wildcard licenses grant the auto_router feature through a reusable feature-entitlement helper

  • Supports wildcard claims in list and scalar forms
  • Preserves the one-router limit for licenses without the required entitlement
  • Adds direct and signed-license regression coverage for wildcard behavior

Reviews (1) · Last reviewed commit: "fix(license): let a wildcard allowed_fea..."

@codecov

codecov Bot commented Sep 17, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@mateo-berri

Copy link
Copy Markdown
Contributor

bugbot run

@cursor cursor Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ 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 c2fbb11. Configure here.

@mateo-berri mateo-berri left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@mateo-berri
mateo-berri merged commit 57d41bd into main Sep 17, 2026
139 of 146 checks passed
@mateo-berri
mateo-berri deleted the litellm_wildcard_license_auto_router branch September 17, 2026 23:11
mateo-berri added a commit that referenced this pull request Sep 17, 2026
fix(license): backport #41684 to stable/1.101.x so a wildcard license grants auto_router
mateo-berri added a commit that referenced this pull request Sep 18, 2026
fix(license): backport the wildcard license auto_router grant to rc/1.102.0 (#41684)
tech-carrement pushed a commit to tech-carrement/litellm that referenced this pull request Sep 20, 2026
…router feature

Backport of BerriAI#41684 to rc/1.102.0.
Cherry-picked from c2fbb11 (litellm_wildcard_license_auto_router).
@mateo-berri mateo-berri removed the backport-stable P0 regression fix only (Urgent ticket): cherry-pick onto the baking rc line before the stable tag label Sep 26, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant