Repository navigation
feat(proxy): report the source of alerting, UI and router settings on read - #41788
Conversation
|
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
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.
…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.
|
@greptileai review |
|
QA PASS: independent before/after run, before at merge base 662e5b6 and after at PR tip f998ab5. Both legs booted a real proxy with Setup shared by both legsSeed phase (config owns none of these keys), writes accepted on both legs: 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: falseGate on each leg: Before (662e5b6, port 8112)
Top-level keys: Top-level keys: After (f998ab5, port 8212)
The row's "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"
}
"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 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.
|
@greptileai review |
|
@greptileai review |
|
QA re-run at tip general_settings:
disable_custom_api_keys: true
enable_chat_ui: falseScenario A: key set in both config.yaml and the stored ui_settings rowStored row seeded through the admin route on the tip proxy: Read on every leg, three times each so both workers answered, identical output each time: Before, merge base {"values": {"disable_custom_api_keys": false, "enable_chat_ui": true, "disable_key_generate_for_org_admin": true}, "source": "absent"}Old tip {"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 {"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:
|
TLDR
Problem this solves:
How it solves it:
sourceconfig,db,env,defaultorunsetUser 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
GET https://litellm-domain/router/settingsand seesnum_retriesis77came from, so they assume the database holds it and they can change itGET https://litellm-domain/get/ui_settingsand likewise see values with no originPOST https://litellm-domain/config/updateto changenum_retriesto9400androuter_settings key 'num_retries' is set in the config file and cannot be changed hereAfter: the same reads label every value with where it came from, so the admin knows before they try
GET https://litellm-domain/router/settingsand seesnum_retriesis7"source": {"num_retries": "config", "allowed_fails": "db", "timeout": "default"}num_retriesis owned by the config file and must be changed there, whileallowed_failsis editableGET https://litellm-domain/get/ui_settingsandGET https://litellm-domain/alerting/settingsand get the same per-key labellingRelevant issues
Affected release
Linear ticket
Resolves LIT-8093
Pre-Submission checklist
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:
Stored rows, chosen to disagree with the file:
Rig gate, run against the PR tip before anything below:
Before (662e5b6)
Alerting settings
curl -sS -H "Authorization: Bearer $MASTER" 'http://127.0.0.1:41122/alerting/settings?_probe=back020_before'source: "unset"— the key exists but is never populated, so it tells the admin nothing:Router settings
curl -sS -H "Authorization: Bearer $MASTER" 'http://127.0.0.1:41122/router/settings?_probe=back020_before'['current_values', 'fields', 'routing_strategy_descriptions']— nosourceat allUI settings
curl -sS -H "Authorization: Bearer $MASTER" 'http://127.0.0.1:41122/get/ui_settings?_probe=back020_before'['field_schema', 'values']— nosourceat allAfter (f998ab5)
Alerting settings
curl -sS -H "Authorization: Bearer $MASTER" 'http://127.0.0.1:41120/alerting/settings?_probe=back020_after'daily_report_frequencyis3600from the file even though the row holds99999, and is labelledconfig.outage_alert_ttlsits only in the row, but because the file declaresalerting_argsthe whole row is shadowed, the proxy serves the default60, and the label saysdefaultrather than claiming a stored value is in effect.Router settings
curl -sS -H "Authorization: Bearer $MASTER" 'http://127.0.0.1:41120/router/settings?_probe=back020_after'num_retriesis the file's7, not the row's555, and is labelledconfig;allowed_failsexists only in the row and is labelleddb.UI settings
curl -sS -H "Authorization: Bearer $MASTER" 'http://127.0.0.1:41120/get/ui_settings?_probe=back020_after'Every returned value has a source.
enable_chat_uiis served from the stored row and labelleddb, 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
Low
/alerting/settingsomitslog_to_console, which is aSlackAlertingArgsfield 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_settingswrites 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