If to click Chess Editor menu on the sidebar and download button then the error message: “500 Internal server error” is displayed.
Error messages:
File "/home/adminuser/venv/lib/python3.14/site-packages/streamlit/web/server/starlette/starlette_gzip_middleware.py", line 105, in send_with_compression
await super().send_with_compression(message)
File "/home/adminuser/venv/lib/python3.14/site-packages/starlette/middleware/gzip.py", line 125, in send_with_compression
await self.send(message)
File "/home/adminuser/venv/lib/python3.14/site-packages/starlette/middleware/sessions.py", line 89, in send_wrapper
await send(message)
File "/home/adminuser/venv/lib/python3.14/site-packages/starlette/middleware/errors.py", line 161, in _send
await send(message)
File "/home/adminuser/venv/lib/python3.14/site-packages/uvicorn/protocols/http/httptools_impl.py", line 473, in send
raise RuntimeError(f"Expected ASGI message 'http.response.start', but got '{message['type']}'.")
RuntimeError: Expected ASGI message 'http.response.start', but got 'http.response.body'.
Welcome to the Streamlit community and thanks for your detailed question! The error “500 Internal server error” with the traceback involving starlette_gzip_middleware and ASGI message types is a known issue that can occur with certain Streamlit and Python versions, especially when using binary file downloads or custom components. This is often triggered by incompatibilities between Streamlit, Starlette, and Uvicorn, or by the way file downloads are handled in the app code.
A similar error was reported and fixed in Streamlit 1.61.1, so upgrading Streamlit to the latest version is recommended. Your current setup uses streamlit==1.58.0 and Python 3.13, which may not be fully compatible with all dependencies. Also, ensure that your download logic uses st.download_button and that files are read fully into memory before passing to the button, as issues can arise if file handles are not managed correctly or if the file is not available at the time of the HTTP request. For more, see the Streamlit download docs and related GitHub issue.