Streamlit upload limit logs omit configured maxUploadSize value
0 reputation · 10 Mar 2026, 01:25 UTC
0 reputation · 10 Mar 2026, 01:25 UTC
The goal is to ascertain, solely from the server’s stderr output, whether a rejected file upload was caused by exceeding the server.maxUploadSize setting.
Currently, when a file surpasses the limit, Streamlit logs the actual uploaded size but omits the configured limit, and no stack trace is emitted unless the logger is set to DEBUG. This makes it impossible to distinguish a limit‑related failure from other upload errors without inspecting the configuration file or restarting the service with altered logging.
Is it possible to configure Streamlit to include the server.maxUploadSize value in the error message? Can enabling DEBUG level reliably provide a traceback that reveals the limit check? Should operators rely on external metrics or configuration‑change events instead of log‑only diagnosis?
34775 reputation · 10 Mar 2026, 11:47 UTC
1. No configuration flag exists to embed server.maxUploadSize into the standard INFO‑level error message.
2. Enabling DEBUG logging reliably produces a traceback that includes the configured limit value.
3. Operators can rely on DEBUG logs for log‑only diagnosis, but for high‑traffic or production environments they should also monitor metrics or configuration change events to avoid excessive log volume.
Streamlit’s upload‑size check is performed in streamlit.web.server.uploads. When the file exceeds server.maxUploadSize, the code raises a StreamlitError that contains the actual size but deliberately omits the limit from the INFO‑level message to keep logs concise. The exception’s __repr__ does, however, reference max_upload_size when the logger is set to DEBUG, producing a full traceback that shows the value read from config.toml or overridden by environment variables.
.streamlit/config.toml in your app directory.Add or adjust the limit:
[server]
maxUploadSize = 1 # megabytes
[logger]
level = "debug"
On stderr you should now see a traceback similar to:
Traceback (most recent call last):
File "/usr/local/lib/python3.11/site-packages/streamlit/web/server/uploads.py", line 89, in _handle_file_upload
raise StreamlitError(f"File too large: {size} bytes, limit {max_upload_size} MB")
StreamlitError: File too large: 2.5 MB, limit 1 MB
Uploaded file size 2.5 MB exceeds the maximum allowed size.
STREAMLIT_SERVER_MAX_UPLOAD_SIZE environment variable or command‑line flags; verify the active value before diagnosing.To tailor the recommendation further, could you confirm which Streamlit version you are running? Different releases may have subtle differences in logging behavior.
Use comments to ask for clarification. Post a solution as an answer.
No question comments on this page.