Bug in st.file_uploader() type='csv' for Streamlit version 1.45.0

  1. The bug manifests itself when running the app in the local machine or deployed to streamlit.app
  2. The app is deployed to the community cloud
    a. FAILS: https://ssscore-bert.streamlit.app/ - Uses Streamlit 1.45.0
    b. WORKS: https://ssscore.streamlit.app/ - Uses Streamlit 1.44.1
  3. Sources: GitHub - pr3d4t0r/SSScoring: Speed Skydiving Scoring - Jupyter Lab notebooks and sample data
  4. Full text of error
    a. Local macOS terminal:
────────────────────────── Traceback (most recent call last) ───────────────────────────
  /Users/ciurana/Python-3_13_3/lib/python3.13/site-packages/streamlit/runtime/scriptru
  nner/exec_code.py:121 in exec_func_with_error_handling
 
  /Users/ciurana/Python-3_13_3/lib/python3.13/site-packages/streamlit/runtime/scriptru
  nner/script_runner.py:599 in code_to_exec
 
  /Users/ciurana/Python-3_13_3/lib/python3.13/site-packages/streamlit/runtime/state/sa
  fe_session_state.py:68 in on_script_will_rerun
 
  /Users/ciurana/Python-3_13_3/lib/python3.13/site-packages/streamlit/runtime/state/se
  ssion_state.py:558 in on_script_will_rerun
 
  /Users/ciurana/Python-3_13_3/lib/python3.13/site-packages/streamlit/runtime/state/se
  ssion_state.py:567 in _call_callbacks
 
  /Users/ciurana/Python-3_13_3/lib/python3.13/site-packages/streamlit/runtime/state/se
  ssion_state.py:579 in _widget_changed
  in get:811
 
  /Users/ciurana/Python-3_13_3/lib/python3.13/site-packages/streamlit/runtime/state/se
  ssion_state.py:128 in __getitem__
 
  /Users/ciurana/Python-3_13_3/lib/python3.13/site-packages/streamlit/elements/widgets
  /file_uploader.py:115 in deserialize
 
  /Users/ciurana/Python-3_13_3/lib/python3.13/site-packages/streamlit/elements/lib/fil
  e_uploader_utils.py:65 in enforce_filename_restriction
────────────────────────────────────────────────────────────────────────────────────────
StreamlitAPIException: Invalid file extension: `.csv`. Allowed: ['.csv']
b. From the Streamlit.app log:
────────────────────── Traceback (most recent call last) ───────────────────────
  /home/adminuser/venv/lib/python3.12/site-packages/streamlit/runtime/scriptru  
  nner/exec_code.py:121 in exec_func_with_error_handling                        
                                                                                
  /home/adminuser/venv/lib/python3.12/site-packages/streamlit/runtime/scriptru  
  nner/script_runner.py:599 in code_to_exec                                     
                                                                                
  /home/adminuser/venv/lib/python3.12/site-packages/streamlit/runtime/state/sa  
  fe_session_state.py:68 in on_script_will_rerun                                
                                                                                
  /home/adminuser/venv/lib/python3.12/site-packages/streamlit/runtime/state/se  
  ssion_state.py:558 in on_script_will_rerun                                    
                                                                                
  /home/adminuser/venv/lib/python3.12/site-packages/streamlit/runtime/state/se  
  ssion_state.py:567 in _call_callbacks                                         
                                                                                
  /home/adminuser/venv/lib/python3.12/site-packages/streamlit/runtime/state/se  
  ssion_state.py:579 in _widget_changed                                         
  in get:807                                                                    
                                                                                
  /home/adminuser/venv/lib/python3.12/site-packages/streamlit/runtime/state/se  
  ssion_state.py:128 in __getitem__                                             
                                                                                
  /home/adminuser/venv/lib/python3.12/site-packages/streamlit/elements/widgets  
  /file_uploader.py:115 in deserialize                                          
                                                                                
  /home/adminuser/venv/lib/python3.12/site-packages/streamlit/elements/lib/fil  
  e_uploader_utils.py:65 in enforce_filename_restriction                        
────────────────────────────────────────────────────────────────────────────────
StreamlitAPIException: Invalid file extension: `.csv`. Allowed: ['.csv']
  1. Versions:
    a. FAILS (Streamlit.app): Python 3.12.10, Streamlit 1.45.0
    b. FAILS (local): Python 3.13.3, Streamlit 1.45.0
    c. WORKS (Streamlit.app): Python 3.12.10, Streamlit 1.44.1
    d. WORKS (local): Python 3.13.3, Streamlit 1.44.1

Test CSV: https://raw.githubusercontent.com/pr3d4t0r/SSScoring/refs/heads/master/resources/test-tracks/FS1/test-data-00.CSV

Link to the only place in the code that uses st.file_uploader(): SSScoring/ssscoring/appcommon.py at 38b44b3f1c1afffdb9da43d61cdcbb8050ae3df0 · pr3d4t0r/SSScoring · GitHub

    if singleTrack:
        trackFile = st.sidebar.file_uploader('Track file', [ 'CSV', 'csv', ], disabled=st.session_state.elevation == None, key = st.session_state.uploaderKey)
        if trackFile:
            st.session_state.trackFile = trackFile
    else:
        trackFiles = st.sidebar.file_uploader(
            'Track files',
            [ 'CSV', 'csv', ],
            disabled=st.session_state.elevation == None,
            accept_multiple_files=True,
            key = st.session_state.uploaderKey
        )

Steps to recreate

  1. Load SSScore 2.4.6 (see link in item 2a)
  2. Set the elevation to 19.0
  3. Upload the test-data-00.CSV file
  4. Crash after upload

Workaround

Follow the same steps, but use SSScore 2.4.5 (link in item 2b), that uses Streamlit 1.44.1 instead of 1.45.0. The code internals are the same.

The deployed and testing Streamlit.app apps have different SSScoring package versions because:

  • SSScoring 2.4.5 requires Streamlit 2.4.5 - WORKS
  • SSScoring 2.4.6 requires Streamlit 2.6.6 - FAILS/BUG

I had to bump the package version in PyPI to to update the requirements.txt that Streamlit.app pulls.

SSScoring 2.4.6 is not tagged. Which commit does it maps to?

Hi Goyo!

The only difference between them is requirements.txt in which 2.4.5 sets the package version of Streamlit to 1.44.1, the other one uses a naked streamlit.

For completeness:

Thanks and cheers!

pr3d

Issue appears to be resolved, we continued and wrapped this conversation on GitHub. Thank you!