diff --git a/src/backend/base/langflow/main.py b/src/backend/base/langflow/main.py index f1bed340d..ef400b312 100644 --- a/src/backend/base/langflow/main.py +++ b/src/backend/base/langflow/main.py @@ -193,9 +193,12 @@ def create_app(): body = await request.body() boundary_start = f"--{boundary}".encode() + # The multipart/form-data spec doesn't require a newline after the boundary, however many clients do + # implement it that way boundary_end = f"--{boundary}--\r\n".encode() + boundary_end_no_newline = f"--{boundary}--".encode() - if not body.startswith(boundary_start) or not body.endswith(boundary_end): + if not body.startswith(boundary_start) or not body.endswith((boundary_end, boundary_end_no_newline)): return JSONResponse( status_code=status.HTTP_422_UNPROCESSABLE_ENTITY, content={"detail": "Invalid multipart formatting"},