Repository navigation
fix(ui): surface SSO and SMTP settings supplied as process env vars - #33576
Conversation
Greptile SummaryFixes LIT-4165 by introducing
Confidence Score: 5/5Safe to merge; the SSO login and mail-send runtime paths are unchanged, and the new resolver is a pure read layer with thorough regression tests covering all precedence branches. The resolver module is pure and well-tested (env-only, stored-wins, blank-stored-falls-to-env, os.environ non-mutation are all pinned). The GET path no longer mutates os.environ, which is a strict improvement. The write path swap from a local env_var_mapping to SSO_FIELD_ENV_VARS is mechanical and verified by the existing update tests. The only remaining observation is a pre-existing duplication between SSOModals.tsx and BaseSSOSettingsForm.tsx that was not consolidated in this PR despite the description stating it was. No files require special attention; the ssoProviderConfigs duplication across SSOModals.tsx and BaseSSOSettingsForm.tsx is a minor maintenance point rather than a functional concern.
|
| Filename | Overview |
|---|---|
| litellm/proxy/config_resolvers/_descriptors.py | New module implementing FieldDescriptor and resolve_fields — clean, pure, well-typed; precedence logic (DB → env → default → unset) and the empty_db_is_set flag are correctly implemented |
| litellm/proxy/config_resolvers/sso.py | SSO-domain resolver; decrypts once via decrypt_value_helper, does not write os.environ, derives SSO_SECRET_FIELDS and SSO_FIELD_ENV_VARS from descriptors so read and write paths share the same source |
| litellm/proxy/config_resolvers/alerting.py | Alerting descriptor tables; SMTP_TLS (missing from the old _email_vars list) is now included; defaults for SMTP_PORT and SMTP_TLS match runtime send-email path behaviour as documented |
| litellm/proxy/ui_crud_endpoints/proxy_setting_endpoints.py | get_sso_settings refactored to use resolve_sso_config; removes legacy proxy_config._decrypt_and_set_db_env_variables call that mutated os.environ on GET; update_sso_settings switches from a local env_var_mapping to the shared SSO_FIELD_ENV_VARS |
| litellm/proxy/proxy_server.py | Email and Slack alerting blocks now resolve via resolve_fields with empty_db_is_set=True; SMTP_TLS (previously missing from the old _email_vars list) is now returned; masking constant is unchanged |
| ui/litellm-dashboard/src/components/email_settings.tsx | Email save now skips any field whose input value equals the server-returned value, preventing masked passwords and env-sourced values from being persisted on every save |
| ui/litellm-dashboard/src/components/SSOModals.tsx | Adds generic_scope field and makes the required flag optional; still maintains its own ssoProviderConfigs in parallel with BaseSSOSettingsForm.tsx rather than importing the exported copy |
| ui/litellm-dashboard/src/components/Settings/AdminSettings/SSOSettings/Modals/BaseSSOSettingsForm.tsx | Adds generic_scope field to both provider configs and exports ssoProviderConfigs for potential reuse; required flag handling is correct |
| tests/test_litellm/proxy/config_resolvers/test_config_resolvers.py | Comprehensive pure-unit tests for the new resolver; covers DB-wins, blank-DB-falls-to-env, empty_db_is_set semantics, os.environ non-mutation, and structured mapping parsing |
| tests/test_litellm/proxy/test_proxy_server.py | Three new regression tests for /get/config/callbacks email block; covers env-only, stored-wins, and absent-everywhere paths; existing tests are unmodified |
| tests/test_litellm/proxy/ui_crud_endpoints/test_proxy_setting_endpoints.py | Five new /get/sso_settings regression tests covering env-only, os.environ non-mutation, stored-wins, blank-stored-falls-to-env, and unset-everywhere paths; existing test updated to swap legacy mock for the new per-value decrypt_value_helper mock |
Reviews (7): Last reviewed commit: "fix(ui): resolve SSO and SMTP settings f..." | Re-trigger Greptile
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
|
@greptileai on the P2 about
Making an omitted field a no-op would leave So Genuine partial-update semantics for this endpoint would be a separate change with its own blast radius (it would break provider switching in the UI unless the form starts sending explicit nulls for the other provider's fields), so it is not something I want to slip into an RC bug fix. |
|
That's a thorough and convincing walkthrough. The omit-means-clear contract being load-bearing for provider switching is the key point — special-casing The UI always round-tripping the field and the |
|
Following up on my own reply above, because the argument I made had a hole worth closing rather than leaving as prose. I justified keeping the behaviour on the grounds that the UI always round-trips On the underlying behaviour, this is deliberate rather than an oversight, and the reasoning is that omit-means-clear is load-bearing rather than incidental: provider switching submits only the selected provider's fields and depends on the other provider's env vars being cleared to take effect without a restart. Verified live at Your P2 does point at something real underneath it though, and it is broader than |
3c42fbf to
05fda6b
Compare
|
Squashed the three commits into one ( |
|
Runtime-tested head Caveat: actual SMTP delivery was not attempted because the runtime used a dummy host; the Test Email Alerts control was present
Recording and runtime notesThe initial SSO view was captured before any UI save; a disposable Proxy Admin Email was then supplied because the existing edit form requires it for the save/reopen scope check CI at test time was 108 passed, 1 failed, 0 pending, 1 skipped; the failing job was Test session: https://app.devin.ai/sessions/f03da2725ec94d28b3facf766871b102 |
|
bugbot run |
05fda6b to
4d532ca
Compare
|
Upgraded this PR from the per-endpoint env fallback to a proper typed config object ( |
4d532ca to
6966d93
Compare
|
Follow-up on |
|
bugbot run |
6966d93 to
c397f9f
Compare
|
Rebased onto latest |
c397f9f to
b04f2df
Compare
|
Rebased again onto latest staging (another 34 commits had landed). This time the conflict was in |
|
bugbot run |
The SSO and Email Server settings pages read only stored config, so a gateway configured entirely through environment variables rendered every field blank even though both features were live. Rather than add per-endpoint env fallback, resolve each setting through one typed config object. A FieldDescriptor names, for one setting, where it lives in the stored row (db_key), which process env var carries it (env_var), whether it is a secret, and its effective default. A pure resolve_fields reconciles a descriptor table against the stored row and the process environment with a fixed precedence and reports per-field provenance (db, env, default, or unset). The SSO descriptor table single-sources the field-to-env mapping that the read and write paths previously duplicated, so they can no longer drift. get_sso_settings and the /get/config/callbacks alerting block read through the resolver instead of their own inline fallbacks. get_sso_settings no longer decrypts stored values into os.environ; decryption happens once inside the resolver via the pure helper, so a GET stops mutating the process environment. The SSO response carries provenance so the UI can distinguish an env-sourced value from a stored one, and secrets are masked at the endpoint (the resolver returns them unmasked so the login path could consume them). os.environ remains the runtime carrier; the SSO login and mail-send paths are unchanged. The settings pages also submit only fields an admin actually edited, so a rendered mask or env-sourced value is never written back over a working secret, and generic_scope is a real SSO form field. Omitting a field from /update/sso_settings clears it, which provider switching relies on; the deeper write-path concern that behaviour points at is tracked in LIT-4498.
|
Good catch on the duplication. Two parts to it: The correctness concern (SSOModals could clear GENERIC_SCOPE on save) was not actually reachable on Fixed properly in |
b04f2df to
0c8e7d9
Compare
|
Confirmed — |
|
bugbot run |
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 0c8e7d9. Configure here.
9baea68
into
litellm_internal_staging
Relevant issues
Linear ticket
Resolves LIT-4165
Pre-Submission checklist
Please complete all items before asking a LiteLLM maintainer to review your PR
@greptileaito 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
A gateway configured the way an IaC shop configures one, every SSO and SMTP setting supplied as a process env var with nothing written through the UI, captured at
4d532cab05Read-back resolves from env, with per-field provenance and masked secrets
The bracketed tag is the new per-field provenance the resolver returns. Before this change these endpoints read only the stored row, so every value above came back null and the SSO page rendered its empty-state placeholder while SSO logins were succeeding
The features are genuinely live (same proxy, same moment)
A stored value overrides env (provenance flips to db), other fields still resolve from env
UI verification for a reviewer
Start the proxy with the environment above, run
npm run devinui/litellm-dashboard, thenopenid email profile groups/get/config/callbacksthat SMTP_PASSWORD was not overwritten with its maskType
🐛 Bug Fix
Changes
The SSO and Email Server settings pages read only stored config, while the features resolve from
os.environ, so a gateway configured entirely through env vars showed blank settings pages despite SSO logins succeeding and mail sending. Rather than add per-endpoint env fallback, this resolves each setting through one typed config objectlitellm/proxy/config_resolvers/holds the resolver: aFieldDescriptornames, for one setting, where it lives in the stored row (db_key), which env var carries it (env_var), whether it is a secret, and its effective default; a pureresolve_fieldsreconciles a descriptor table against the stored row and the process environment with a fixed precedence (a set stored value wins, else a non-blank env var, else the default, else unset) and returns per-field provenance. The SSO descriptor table single-sources the field-to-env mapping the read and write paths previously duplicated, so they can no longer drift. Precedence is db then env because for these two domains yaml is not a separate typed source; a yamlenvironment_variables:block only populates envget_sso_settingsand the/get/config/callbacksalerting block read through the resolver instead of their own inline fallbacks.get_sso_settingsno longer decrypts stored values intoos.environ; decryption happens once inside the resolver via the pure helper, so a GET stops mutating the process environment, which previously masked any consumer that stopped reading it. The SSO response carries provenance so the UI can tell an env-sourced value from a stored one, and secrets are masked at the endpoint while the resolver returns them unmasked so the login path could consume them.os.environstays the runtime carrier and the SSO login and mail-send paths are unchanged; retiring the carrier is tracked separately in LIT-4498A present-but-empty stored value is read differently per domain, which two tests pin: for SSO it is treated as absent and falls back to env (SSO's clear path also unsets the env var), and for the alerting blob an explicit empty is an admin clear that wins over a stale env var.
generic_scope,SMTP_PORTandSMTP_TLScarry the same effective defaults their features apply, so the settings page shows the config that would actually be used rather than a blankThe settings pages also submit only fields an admin actually edited so a rendered mask or env-sourced value is never written back over a working secret,
generic_scopeis a real SSO form field, and the duplicatessoProviderConfigsin the two SSO forms is consolidated. Omitting a field from/update/sso_settingsclears it, which provider switching relies on; the deeper write-path concern that behaviour points at is tracked in LIT-4498Note
Medium Risk
Touches SSO and SMTP configuration read paths and GET semantics (no longer mutating os.environ), but behavior is pinned with extensive tests and login/mail runtime paths are unchanged.
Overview
Fixes LIT-4165: admin read APIs for SSO and email alerting only looked at stored config, so Helm/IaC deployments with live settings in
os.environshowed empty UI while login and mail still worked.Adds
litellm/proxy/config_resolvers/withFieldDescriptortables andresolve_fields(DB → env → default → unset, plus per-field provenance). SSO and alerting use different rules for empty stored values (empty_db_is_set: alerting treats""as an explicit clear; SSO treats blanks as absent)./get/sso_settingsnow usesresolve_sso_configinstead of inline DB assembly and no longer decrypts intoos.environon GET. The response includes provenance; SSO field→env mapping is single-sourced viaSSO_FIELD_ENV_VARS/SSO_SECRET_FIELDSfor read and write./get/config/callbacksemail and Slack blocks use the alerting descriptors with env fallback and SMTP defaults (587,True).Dashboard:
generic_scopeon SSO types/forms/display; email save submits only changed fields so masked/env values are not persisted; duplicate SSO form config consolidated intoBaseSSOSettingsForm.Reviewed by Cursor Bugbot for commit 0c8e7d9. Bugbot is set up for automated code reviews on this repo. Configure here.