AxiosError 400 on Streamlit Cloud when uploading any file type with Korean (non-ASCII) filenames

Subject: AxiosError 400 on Streamlit Cloud when uploading .txt files with Korean (non-ASCII) filenames

Hi Streamlit Team and Community,

Iโ€™m encountering a persistent AxiosError: Request failed with status code 400 when trying to upload certain .txt files to my app deployed on Streamlit Cloud. The issue appears to be specifically related to .txt files with Korean (non-ASCII) characters in their filenames.

Environment:

  • Deployment: Streamlit Cloud
  • Streamlit Version: 1.45.1 (from app logs)
  • Python Version: 3.10.17 (from app logs)
  • Browser: Microsoft Edge (though the issue seems server-side)

Problem Description & Steps to Reproduce:

I have a file uploader in my app (st.file_uploader).

  1. When I try to upload a .txt file named ์•ˆ๋…•.txt (Korean for โ€œhelloโ€) which contains the UTF-8 encoded text โ€œ์•ˆ๋…•โ€ (6 bytes: b'\xec\x95\x88\xeb\x85\x95'), the browserโ€™s console shows an AxiosError: Request failed with status code 400. The request is to a /_stcore/upload_file/... endpoint. The Streamlit Cloud application logs for app.py show no specific Python errors or any custom debug print statements Iโ€™ve placed at the beginning of my file processing function (extract_text_from_file) for this failed attempt. This suggests the rejection is happening before my Python code for file handling is significantly invoked.
  2. If I rename the exact same file (content โ€œ์•ˆ๋…•โ€) to an ASCII filename like hello.txt and upload it, the upload is successful. My application correctly reads the file, and the Python print statements confirm the bytes (b'\xec\x95\x88\xeb\x85\x95') and correctly decodes the content as โ€œ์•ˆ๋…•โ€ using UTF-8.
  3. Uploading .docx files (e.g., 13.2 KB) works fine, even if their content is Korean (filenames for these were ASCII in my tests).
  4. Uploading .txt files with only English characters in their content AND ASCII filenames also works fine.

Observations & Hypothesis:

The key differentiating factor for the 400 error seems to be the Korean (non-ASCII) filename for .txt files. The file content itself (โ€œ์•ˆ๋…•โ€) is correctly processed if the filename is ASCII.

This leads me to hypothesize that the issue might lie in how Streamlit Cloudโ€™s infrastructure (perhaps the frontend file uploader, the backend Nginx/proxy, or the initial file receiver before the Python UploadedFile object is fully formed for the app script) handles HTTP requests with non-ASCII filenames, specifically for text/plain MIME types, or how filenames are encoded in the Content-Disposition header of the multipart/form-data request.

The AxiosError 400 suggests the server considers the request malformed when a Korean filename is used for a .txt file.

Minimal Test Case:

I deployed a minimal test app to Streamlit Cloud (test_upload.py) to isolate this:

import streamlit as st
import traceback

st.title("Minimal TXT File Upload Test")
uploaded_file = st.file_uploader("Upload a TXT file", type=["txt"])

if uploaded_file is not None:
    st.write(f"Name: {uploaded_file.name}")
    st.write(f"Size: {uploaded_file.size} bytes")
    st.write(f"Type (MIME): {uploaded_file.type}")
    try:
        file_bytes = uploaded_file.getvalue()
        st.write(f"Successfully read {len(file_bytes)} bytes.")
        st.write(f"Raw Bytes (first 20): {file_bytes[:20]!r}")
        decoded_text_utf8 = file_bytes.decode('utf-8', errors='replace')
        st.write(f"Decoded as UTF-8 (first 50 chars): {decoded_text_utf8[:50]!r}")
        st.success("File processed.")
    except Exception as e:
        st.error(f"Error processing file: {e}")
        st.code(traceback.format_exc())

With this minimal app on Streamlit Cloud:

  • Uploading ์•ˆ๋…•.txt (content โ€œ์•ˆ๋…•โ€) -> Results in AxiosError 400 in browser. No output on the Streamlit page itself (as the file isnโ€™t successfully passed to the Python script).
  • Uploading hello.txt (content โ€œ์•ˆ๋…•โ€) -> Works perfectly, displays filename, size, bytes, and decoded content โ€œ์•ˆ๋…•โ€.

Request:
Could you please look into this? Is this a known limitation or a potential bug in how non-ASCII filenames for .txt files (or text/plain types) are handled by Streamlit Cloudโ€™s file upload mechanism? Are there any recommended configurations or workarounds other than advising users to use only ASCII filenames?

Thank you for your time and help!

1 Like

The same thing is happening. There are no issues when I run the app directly on my local machine, but I observe the same behavior when running it in a local Docker environment or on Azure App Service.
In my case, the issue occurs when there are Japanese (non-ASCII) characters in the file name.
My environment:
Python 3.10.12
Streamlit 1.38.0 (Downgrading to 1.24.0 or other versions did not help)

I think this error didnโ€™t occur with exactly the same code until a few weeks ago.

2 Likes

I found the same issue on GitHub Issues(file_uploader fails for files with Unicode characters in filename (Streamlit Community Cloud) ยท Issue #11396 ยท streamlit/streamlit ยท GitHub),
and a solution was suggested there.
Including
tornado<=6.4.2
in requirements.txt resolved the problem!
@dpcks1234
You should give it a try!

2 Likes