Internal server error and RuntimeError on Streamlit Cloud

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'.

Python 3.13

pyvips==3.1.1
pyvips-binary==8.18.4
streamlit==1.58.0
streamlit-image-coordinates==0.4.0
stockfish==5.2.0
python-chess==1.999
python-gettext
matplotlib==3.10.8
validators==0.35.0

Welcome to the Streamlit community and thanks for your detailed question! :blush: 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.

Sources:

After updating Streamlit to version 1.61.1 got an error message:


ImportError: cannot import name 'UseColumnWith' from 'streamlit.elements.image'

(/home/adminuser/venv/lib/python3.14/site-packages/streamlit/elements/image.py)

The module streamlit_image_coordinates is developed by Streamlit team. What to do? Is there a new version that works?

streamlit-image-coordinates==0.4.0