forked from SWISDATA/processintel
app: the STREAMLIT_* environment variable translation can crash the app at startup #24
Labels
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
ffrauenberger/ProcessIntel#24
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Severity: low (only some environment values trigger it)
Where
app/__main__.py:7-44Problem
The entry point translates
STREAMLIT_*environment variables into Streamlit config keys:env_to_config_keyassumes at least two_-separated parts after the prefix. A variable such asSTREAMLIT_FOOgivesoption = [], andoption[0]raisesIndexErroroutside thetry, so the service fails to start because of an unrelated environment variable.env_key[10:]hard-codes the length of"STREAMLIT_"althoughprefixis a parameter.theme.light.sidebar.fontbecomestheme.lightSidebarFont. Acronyms other thanenableCORSare converted to camelCase naively (server.enableXsrfProtectiononly works by chance).parse_env_valuehandles only bools and non-negative ints; floats and negative numbers stay strings, whichconfig.set_optionmay reject.printed instead of logged.Steps to reproduce
STREAMLIT_FOO=1python -m appExpected behavior
Unknown or malformed variables are ignored (with a logged warning), and the app starts.
Actual behavior
The app crashes at startup with
IndexError.Fix
Use an explicit allow-list mapping from environment variables to config keys, or rely on Streamlit's own
--server.*CLI flags /config.toml. Do the parsing inside thetryand log errors.from
issues/BUG-024-streamlit-env-var-translation-is-fragile.md(code analysis of commit6bcc646, 2026-10-03)Reviewed by Codex (GPT-6) against origin/main
6bcc646eb464.Review: partially correct.
The startup crash for
STREAMLIT_FOOand limited value parsing are supported. Two textual details need correction:prefixis a parameter ofapply_streamlit_env, notenv_to_config_key; the latter always strips ten characters. Also,server.enableXsrfProtectionis the correct Streamlit 1.58 configuration spelling, not an accidental casing success. The reviewed Nix environment accepts it and returns its value. Keep the malformed-variable, nested-section and custom-prefix findings without implying that this particular XSRF mapping is broken.Code references: app/main.py:18, app/main.py:32.