From 1236643711fa0618b8ee80bcd088781c0c92eb29 Mon Sep 17 00:00:00 2001 From: Ilia Krupin <46923587+krupibox@users.noreply.github.com> Date: Fri, 13 Jun 2025 19:26:08 +0300 Subject: [PATCH] fix: 500 error when downloading projects with non-ASCII characters (ex. Cyrillic) names (#8483) * fix: encode Cyrillic filenames in Content-Disposition header * [autofix.ci] apply automated fixes --------- Co-authored-by: Ilia Krupin Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com> Co-authored-by: Gabriel Luiz Freitas Almeida --- src/backend/base/langflow/api/v1/projects.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/backend/base/langflow/api/v1/projects.py b/src/backend/base/langflow/api/v1/projects.py index 19c33bef5..9cf5600ed 100644 --- a/src/backend/base/langflow/api/v1/projects.py +++ b/src/backend/base/langflow/api/v1/projects.py @@ -3,6 +3,7 @@ import json import zipfile from datetime import datetime, timezone from typing import Annotated +from urllib.parse import quote from uuid import UUID import orjson @@ -292,17 +293,20 @@ async def download_file( with zipfile.ZipFile(zip_stream, "w") as zip_file: for flow in flows_without_api_keys: flow_json = json.dumps(jsonable_encoder(flow)) - zip_file.writestr(f"{flow['name']}.json", flow_json) + zip_file.writestr(f"{flow['name']}.json", flow_json.encode("utf-8")) zip_stream.seek(0) current_time = datetime.now(tz=timezone.utc).astimezone().strftime("%Y%m%d_%H%M%S") filename = f"{current_time}_{project.name}_flows.zip" + # URL encode filename handle non-ASCII (ex. Cyrillic) + encoded_filename = quote(filename) + return StreamingResponse( zip_stream, media_type="application/x-zip-compressed", - headers={"Content-Disposition": f"attachment; filename={filename}"}, + headers={"Content-Disposition": f"attachment; filename*=UTF-8''{encoded_filename}"}, ) except Exception as e: