Skip to content

feat(proxy): report the source of alerting, UI and router settings on read - #41788

Merged
yuneng-berri merged 11 commits into
mainfrom
litellm_config_read_source
Sep 22, 2026
Merged

yuneng-berri merged 11 commits into
mainfrom
litellm_config_read_source

Conversation

@yuneng-berri

@yuneng-berri yuneng-berri commented Sep 18, 2026 •

Copy link
Copy Markdown
Contributor

TLDR

Problem this solves:

  • An admin cannot tell why a setting has the value it has
  • The config file, the database and the default are indistinguishable
  • Editing a frozen setting fails only after the write is attempted

How it solves it:

  • Alerting, UI and router reads now report a per-key source
  • Source is config, db, env, default or unset
  • The reported source matches the value the proxy actually serves

User Flow

Before: an admin looking at alerting, UI or router settings cannot tell which values the config file controls, so they discover a setting is frozen only when saving it fails

  1. The admin opens GET https://litellm-domain/router/settings and sees num_retries is 7
  2. The response carries no indication of where 7 came from, so they assume the database holds it and they can change it
  3. They open GET https://litellm-domain/get/ui_settings and likewise see values with no origin
  4. They send POST https://litellm-domain/config/update to change num_retries to 9
  5. The call fails with 400 and router_settings key 'num_retries' is set in the config file and cannot be changed here

After: the same reads label every value with where it came from, so the admin knows before they try

  1. The admin opens GET https://litellm-domain/router/settings and sees num_retries is 7
  2. The response now also carries "source": {"num_retries": "config", "allowed_fails": "db", "timeout": "default"}
  3. They can see num_retries is owned by the config file and must be changed there, while allowed_fails is editable
  4. They open GET https://litellm-domain/get/ui_settings and GET https://litellm-domain/alerting/settings and get the same per-key labelling
  5. They edit the config file for the frozen keys and use the API for the rest, with no failed write

Relevant issues

Affected release

Linear ticket

Resolves LIT-8093

Pre-Submission checklist

  • I have added meaningful tests
  • The handful of test files covering my change pass locally
  • My PR passes all required CI/CD checks
  • 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

Screenshots / Proof of Fix

Shared setup for both runs: one throwaway PostgreSQL, one mock upstream, and the same config file, deliberately made to disagree with the stored rows.

Config file:

general_settings:
  alerting: ["slack"]
  alerting_args:
    daily_report_frequency: 3600
    report_check_interval: 300
router_settings:
  routing_strategy: latency-based-routing
  num_retries: 7
litellm_settings:
  ui_settings:
    enable_chat_ui: false

Stored rows, chosen to disagree with the file:

general_settings -> {"alerting_args": {"daily_report_frequency": 99999, "outage_alert_ttl": 4242, "region_outage_alert_ttl": []}}
router_settings  -> {"num_retries": 555, "allowed_fails": 12}
ui_settings      -> {"enable_chat_ui": true}

Rig gate, run against the PR tip before anything below:

$ curl -sS -H "Authorization: Bearer $MASTER" 'http://127.0.0.1:41120/v1/models?_probe=gate'
{"data": [{"id": "proof-model", ...}], "object": "list"}

$ curl -sS -H "Authorization: Bearer $MASTER" -X POST 'http://127.0.0.1:41120/v1/chat/completions?_probe=gate' \
    -d '{"model":"proof-model","messages":[{"role":"user","content":"ping"}]}'
model: proof-model | choices: 1 | usage: {'completion_tokens': 20, 'prompt_tokens': 20, 'total_tokens': 40}

Before (662e5b6)

Alerting settings

  1. curl -sS -H "Authorization: Bearer $MASTER" 'http://127.0.0.1:41122/alerting/settings?_probe=back020_before'
  2. 15 fields come back and every one reports source: "unset" — the key exists but is never populated, so it tells the admin nothing:
daily_report_frequency   value=3600  source=unset
outage_alert_ttl         value=60    source=unset

Router settings

  1. curl -sS -H "Authorization: Bearer $MASTER" 'http://127.0.0.1:41122/router/settings?_probe=back020_before'
  2. Top-level keys are ['current_values', 'fields', 'routing_strategy_descriptions'] — no source at all

UI settings

  1. curl -sS -H "Authorization: Bearer $MASTER" 'http://127.0.0.1:41122/get/ui_settings?_probe=back020_before'
  2. Top-level keys are ['field_schema', 'values'] — no source at all

After (f998ab5)

Alerting settings

  1. curl -sS -H "Authorization: Bearer $MASTER" 'http://127.0.0.1:41120/alerting/settings?_probe=back020_after'
  2. Every field reports a real source, and each one matches the value actually served:
slack_alerting           value=True   source=config
daily_report_frequency   value=3600   source=config
report_check_interval    value=300    source=config
budget_alert_ttl         value=86400  source=default
outage_alert_ttl         value=60     source=default
region_outage_alert_ttl  value=60     source=default
fields returned without a source: []

daily_report_frequency is 3600 from the file even though the row holds 99999, and is labelled config. outage_alert_ttl sits only in the row, but because the file declares alerting_args the whole row is shadowed, the proxy serves the default 60, and the label says default rather than claiming a stored value is in effect.

Router settings

  1. curl -sS -H "Authorization: Bearer $MASTER" 'http://127.0.0.1:41120/router/settings?_probe=back020_after'
routing_strategy   value=latency-based-routing  source=config
num_retries        value=7                      source=config
allowed_fails      value=12                     source=db
timeout            value=6000.0                 source=default
values without a source: []

num_retries is the file's 7, not the row's 555, and is labelled config; allowed_fails exists only in the row and is labelled db.

UI settings

  1. curl -sS -H "Authorization: Bearer $MASTER" 'http://127.0.0.1:41120/get/ui_settings?_probe=back020_after'
enable_chat_ui  value=True  source=db
total values: 18 | total sources: 18

Every returned value has a source. enable_chat_ui is served from the stored row and labelled db, which is the precedence the UI-settings row already has today — this PR reports that precedence, it does not change it.

Type

New Feature

Caveats

Medium

  • UI settings declared only in the config file now reach this read. Before, this endpoint consulted the stored row alone and fell back to the class default, so an admin who set a UI flag in the config file and never saved it in the UI saw the default; they now see the file's value. The stored row still wins where both are set.

Low

  • /alerting/settings omits log_to_console, which is a SlackAlertingArgs field but is not in the endpoint's allow-list, so it has no entry and therefore no source. Pre-existing on the base branch and left alone here.
  • /get/ui_settings writes the stored UI flags into the shared settings state as a side effect of the read. Pre-existing on the base branch, unchanged by this PR, and reported rather than fixed here to keep the scope to reporting.

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

@greptile-apps

greptile-apps Bot commented Sep 18, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerConfidence Score: 5/5

The PR appears safe to merge, with no outstanding correctness or repository-rule violations identified

Summary

The PR adds per-setting provenance to alerting, router, and UI settings reads so administrators can distinguish config, database, environment, default, and unset values

  • Adds shared source-resolution helpers and response schema fields
  • Aligns source labels with resolved values for nested alerting arguments and router defaults
  • Extends UI settings reads to include configured values and derived feature-flag provenance
  • Adds focused regression coverage for config, database, default, unset, and conflicting-value cases

Reviews (4) · Last reviewed commit: "Merge remote-tracking branch 'origin/mai..."

Comment thread litellm/proxy/proxy_server.py Resolved
@codecov

codecov Bot commented Sep 18, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 97.05882% with 2 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
litellm/proxy/proxy_server.py 95.65% 1 Missing ⚠️
...proxy/ui_crud_endpoints/proxy_setting_endpoints.py 96.29% 1 Missing ⚠️

📢 Thoughts on this report? Let us know!

Base automatically changed from litellm_settings_store_precedence to main September 18, 2026 16:52
@yucheng-berri
yucheng-berri requested a review from a team September 18, 2026 16:52
The shared settings-store work this branch was stacked on landed on main,
along with source reporting for /config/field/info and /config/list.
Resolved by taking main for the store, the config routes and their tests,
and re-applying only the read surfaces main does not cover:
/alerting/settings, /get/ui_settings and /router/settings.
…over

/config/field/info and /config/list already report per-key source on main,
so this drops the branch's versions of those and keeps /alerting/settings,
/get/ui_settings and /router/settings.

Read endpoints no longer write the freshly read database row back into the
shared settings store; the reload path already keeps it current, and a GET
that mutates global state leaks across callers.

Regenerates the lazy OpenAPI snapshot on Python 3.12, matching CI, and the
dashboard API types for the two new response fields.
@codspeed

codspeed Bot commented Sep 21, 2026 •

Copy link
Copy Markdown
Contributor

Merging this PR will not alter performance

✅ 31 untouched benchmarks


Comparing litellm_config_read_source (143725f) with main (5fb66e8)

Open in CodSpeed

…urces

_nested_setting_source returned "db" whenever the stored row held a value,
without first asking whether the config file declares the same key. For a
config-owned alerting_args field that disagrees with the database, the
endpoint reported source "db" while the proxy actually serves the file's
value and rejects any write to it.

Config ownership is now checked first, matching SettingsStore.source and
the precedence the rest of the resolver applies. The source test set grows
a field that only the database sets, a field only the file sets, and a
stored empty list, so each reported source is discriminating.
…d row

When the config file declares alerting_args at all, the resolver hands the
file's dict to every reader and the stored row never reaches one. Reporting
a nested field as "db" because the row happens to carry it told the admin a
value was in effect that the proxy does not serve: a live proxy answered
source "db" for outage_alert_ttl while serving the default.

A config-owned parent now reports the field's own default, and the DB is
consulted only when the file leaves the parent alone.
@yuneng-berri yuneng-berri changed the title feat(proxy): report sources in config read endpoints feat(proxy): report the source of alerting, UI and router settings on read Sep 21, 2026
@yuneng-berri

Copy link
Copy Markdown
Contributor Author

@greptileai review

@devin-ai-integration

Copy link
Copy Markdown
Contributor

QA PASS: independent before/after run, before at merge base 662e5b6 and after at PR tip f998ab5. Both legs booted a real proxy with --num_workers 2 against its own fresh Postgres, seeded the stored rows through the admin API (not SQL), then read the three endpoints 4 times each so both workers served them (all 4 responses byte-identical per endpoint on both legs). The gate on each leg was a real OpenAI gpt-4.1-mini completion through the proxy that returned pong

Setup shared by both legs

Seed phase (config owns none of these keys), writes accepted on both legs:

curl -sS -H "Authorization: Bearer $MASTER" -X POST http://127.0.0.1:$PORT/config/update -H 'Content-Type: application/json' \
  -d '{"router_settings":{"num_retries":555,"allowed_fails":12},"general_settings":{"alerting_args":{"daily_report_frequency":99999,"outage_alert_ttl":4242}}}'
{"message": "Config updated successfully"}

curl -sS -H "Authorization: Bearer $MASTER" -X PATCH http://127.0.0.1:$PORT/update/ui_settings -H 'Content-Type: application/json' -d '{"enable_chat_ui":true}'
{"message": "UI settings updated successfully", "status": "success", "settings": {"enable_chat_ui": true}}

Read phase config, deliberately disagreeing with the rows above:

model_list:
  - model_name: gpt-4.1-mini
    litellm_params:
      model: openai/gpt-4.1-mini
      api_key: os.environ/OPENAI_API_KEY
general_settings:
  master_key: os.environ/LITELLM_MASTER_KEY
  database_url: os.environ/DATABASE_URL
  alerting: ["slack"]
  alerting_args:
    daily_report_frequency: 3600
    report_check_interval: 300
  disable_custom_api_keys: true
router_settings:
  routing_strategy: latency-based-routing
  num_retries: 7
litellm_settings:
  ui_settings:
    enable_chat_ui: false

Gate on each leg:

curl -sS -H "Authorization: Bearer $MASTER" -X POST http://127.0.0.1:$PORT/v1/chat/completions -H 'Content-Type: application/json' \
  -d '{"model":"gpt-4.1-mini","messages":[{"role":"user","content":"Reply with the single word pong"}]}'
model: gpt-4.1-mini | content: pong | usage: {"completion_tokens": 1, "prompt_tokens": 13, "total_tokens": 14}
Before (662e5b6, port 8112)
curl -sS -H "Authorization: Bearer $MASTER" http://127.0.0.1:8112/alerting/settings
field value source
slack_alerting true unset
daily_report_frequency 3600 unset
report_check_interval 300 unset
outage_alert_ttl 60 unset
budget_alert_ttl 86400 unset
(all 15 fields) unset
curl -sS -H "Authorization: Bearer $MASTER" http://127.0.0.1:8112/router/settings

Top-level keys: fields, current_values, routing_strategy_descriptions. No source anywhere. num_retries 7, allowed_fails 12, no way to tell which is frozen

curl -sS -H "Authorization: Bearer $MASTER" http://127.0.0.1:8112/get/ui_settings

Top-level keys: values, field_schema. No source. Also disable_custom_api_keys is served as false even though the config file sets it true

After (f998ab5, port 8212)
curl -sS -H "Authorization: Bearer $MASTER" http://127.0.0.1:8212/alerting/settings
field value source
slack_alerting true config
daily_report_frequency 3600 config
report_check_interval 300 config
budget_alert_ttl 86400 default
outage_alert_ttl 60 default
region_outage_alert_ttl 60 default
minor_outage_alert_threshold 5 default
major_outage_alert_threshold 10 default
max_outage_alert_list_size 10 default
daily_spend_per_user_threshold null unset
monthly_spend_per_user_threshold null unset
spend_anomaly_multiplier 3.0 default
spend_anomaly_baseline_days 7 default
spend_anomaly_min_spend 10.0 default
user_spend_check_interval 3600 default

The row's daily_report_frequency: 99999 and outage_alert_ttl: 4242 are shadowed because the file owns alerting_args; the labels match the served values, not the stored ones

curl -sS -H "Authorization: Bearer $MASTER" http://127.0.0.1:8212/router/settings
"source": {
  "routing_groups": "default",
  "routing_strategy": "config",
  "routing_strategy_args": "default",
  "num_retries": "config",
  "timeout": "default",
  "stream_timeout": "unset",
  "max_fallbacks": "default",
  "fallbacks": "default",
  "context_window_fallbacks": "default",
  "content_policy_fallbacks": "default",
  "allowed_fails": "db",
  "cooldown_time": "default",
  "retry_after": "default",
  "retry_policy": "unset",
  "model_group_alias": "default",
  "enable_pre_call_checks": "default",
  "default_litellm_params": "default",
  "set_verbose": "default",
  "default_max_parallel_requests": "unset",
  "enable_tag_filtering": "default",
  "tag_filtering_match_any": "default",
  "disable_cooldowns": "unset"
}

current_values.num_retries is the file's 7 (row holds 555) labelled config; allowed_fails 12 exists only in the row and is labelled db

curl -sS -H "Authorization: Bearer $MASTER" http://127.0.0.1:8212/get/ui_settings
"values": {"disable_custom_api_keys": true, "enable_chat_ui": true, ...16 more},
"source": {
  "disable_custom_api_keys": "config",
  "enable_chat_ui": "db",
  "enabled_ui_pages_internal_users": "unset",
  "...15 others": "default"
}

All 18 values carry a source

Observations, none of which block the PR. Before the PR /get/ui_settings served disable_custom_api_keys: false despite the config file setting true, and this PR also fixes the served value. Config litellm_settings.ui_settings.enable_chat_ui: false loses to the stored row and is reported as db, which matches existing precedence rather than changing it. Router fallbacks is served null but labelled default (the field default is []); that label is new in this PR and looks cosmetic. Alerting outage_alert_ttl shows stored_in_db: true next to source: default, which is consistent with shadowing but reads oddly

Full command transcripts and raw JSON bodies for every call are kept in the QA run logs and can be attached on request

A stored null or empty list for a nested alerting field is still the value
the proxy serves when the config file leaves alerting_args alone, so the
source is db. Keying off the value rather than its presence reported those
fields as default and hid a stored setting that is genuinely in effect.

Presence in the stored row now decides, with the config file still checked
first so a config-owned key keeps reporting config. Test helpers are typed
and the router test injects a stub rather than patching a class attribute.
@yuneng-berri

Copy link
Copy Markdown
Contributor Author

@greptileai review

@yuneng-berri

Copy link
Copy Markdown
Contributor Author

@greptileai review

@devin-ai-integration

Copy link
Copy Markdown
Contributor

QA re-run at tip 143725fc06 (merge base 5fb66e8d98, old proven tip f998ab53d5). Each leg is a separate worktree booted with --num_workers 2 against a fresh Postgres, using the same config file:

general_settings:
  disable_custom_api_keys: true
  enable_chat_ui: false

Scenario A: key set in both config.yaml and the stored ui_settings row

Stored row seeded through the admin route on the tip proxy:

$ curl -sS -H "Authorization: Bearer $MASTER" -H 'Content-Type: application/json' -X PATCH http://127.0.0.1:41301/update/ui_settings \
    -d '{"disable_custom_api_keys": false, "enable_chat_ui": true, "disable_key_generate_for_org_admin": true}'
{"message":"UI settings updated successfully","status":"success","settings":{"disable_custom_api_keys":false,"disable_key_generate_for_org_admin":true,"enable_chat_ui":true}}

Read on every leg, three times each so both workers answered, identical output each time:

$ curl -sS -H "Authorization: Bearer $MASTER" http://127.0.0.1:<port>/get/ui_settings | jq '{values: (.values | {disable_custom_api_keys, enable_chat_ui, disable_key_generate_for_org_admin}), source: (.source // "absent" | if type=="object" then {disable_custom_api_keys, enable_chat_ui, disable_key_generate_for_org_admin} else . end)}'

Before, merge base 5fb66e8d98 (port 41302): DB wins, no source

{"values": {"disable_custom_api_keys": false, "enable_chat_ui": true, "disable_key_generate_for_org_admin": true}, "source": "absent"}

Old tip f998ab53d5 (port 41303): source present but DB still wins over config

{"values": {"disable_custom_api_keys": false, "enable_chat_ui": true, "disable_key_generate_for_org_admin": true},
 "source": {"disable_custom_api_keys": "db", "enable_chat_ui": "db", "disable_key_generate_for_org_admin": "db"}}

After, tip 143725fc06 (port 41301): config wins and is labelled config, the DB-only key stays db

{"values": {"disable_custom_api_keys": true, "enable_chat_ui": false, "disable_key_generate_for_org_admin": true},
 "source": {"disable_custom_api_keys": "config", "enable_chat_ui": "config", "disable_key_generate_for_org_admin": "db"}}

Scenario B: disable_custom_api_keys: true in config.yaml, no stored row

Tip (port 41311) reports the flag from config:

{"values": {"disable_custom_api_keys": true, "enable_chat_ui": false, "disable_key_generate_for_org_admin": false},
 "source": {"disable_custom_api_keys": "config", "enable_chat_ui": "config", "disable_key_generate_for_org_admin": "default"}}

but the gate does not enforce it, on base or tip:

$ curl -sS -w '\nHTTP_CODE=%{http_code}\n' -H "Authorization: Bearer $MASTER" -H 'Content-Type: application/json' \
    -X POST http://127.0.0.1:<port>/key/generate -d '{"key":"sk-custom-qa-key-1"}'
base 5fb66e8d98 (41312): HTTP_CODE=200, body contains "key":"sk-custom-qa-key-1"
tip  143725fc06 (41311): HTTP_CODE=200, body contains "key":"sk-custom-qa-key-1"

Confirmed: _check_custom_key_allowed reads get_ui_settings_cached(), which only consults the DB row, so a config-only disable_custom_api_keys is reported but not enforced. Identical on the merge base, so this is a pre-existing main bug and not introduced by this PR

Control on tip: after PATCH /update/ui_settings -d '{"disable_custom_api_keys": true}', six /key/generate calls with fresh custom keys returned 403, 200, 403, 200, 200, 403. Each worker keeps its own in-memory copy of the ui_settings cache (600s TTL, no Redis here) and the PATCH only refreshes the worker that served it, so even the DB-backed gate is unreliable across workers. Also pre-existing, this PR leaves it alone

Verdict: PASS for the config-over-DB precedence at 143725fc06. The disable_custom_api_keys enforcement gap is a separate main issue

@yuneng-berri
yuneng-berri merged commit 1f4b595 into main Sep 22, 2026
99 of 100 checks passed
@yuneng-berri
yuneng-berri deleted the litellm_config_read_source branch September 22, 2026 00:02

This branch had an error being deployed

1 failed deployment
e2e-changed — 143725fc Deployed Sep 21, 2026 by yuneng-berri via oauth #179
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.

2 participants