Build Agentic workflows, RAG pipelines, with rich AI model and tool support on one collaborative workspace. Deploy on cloud, VPC, or self-hosted, so teams move from prototype to production without rebuilding the stack.
Python agentagentic-aiagentic-frameworkagentic-workflowaiautomationclaudedeepseekgenaigptllmlow-codemcpnextjsno-codeopenaipythonskillsworkflow
fix(api): return 415 for unsupported pipeline upload file types (#44012)
Stephen Zhou8a237c6daf52
diff --git a/api/controllers/service_api/dataset/rag_pipeline/rag_pipeline_workflow.py b/api/controllers/service_api/dataset/rag_pipeline/rag_pipeline_workflow.pyindex 22167616e76..42b4055b29c 100644--- a/api/controllers/service_api/dataset/rag_pipeline/rag_pipeline_workflow.py+++ b/api/controllers/service_api/dataset/rag_pipeline/rag_pipeline_workflow.py@@ -15,6 +15,7 @@ from controllers.common.errors import (FileTooLargeError,NoFileUploadedError,TooManyFilesError,+ UnsupportedFileTypeError,)from controllers.common.fields import WorkflowBlockingResponsefrom controllers.common.schema import (@@ -40,7 +41,6 @@ from libs.login import current_userfrom models import Accountfrom models.dataset import Dataset, Pipelinefrom models.engine import db-from services.errors.file import UnsupportedFileTypeErrorfrom services.feature_service import FeatureServicefrom services.file_service import FileServicefrom services.rag_pipeline.entity.pipeline_service_api_entities import (diff --git a/api/tests/unit_tests/controllers/service_api/dataset/rag_pipeline/test_rag_pipeline_workflow.py b/api/tests/unit_tests/controllers/service_api/dataset/rag_pipeline/test_rag_pipeline_workflow.pyindex 4cb3d5ec648..6a6d07ed1cd 100644--- a/api/tests/unit_tests/controllers/service_api/dataset/rag_pipeline/test_rag_pipeline_workflow.py+++ b/api/tests/unit_tests/controllers/service_api/dataset/rag_pipeline/test_rag_pipeline_workflow.py@@ -37,6 +37,9 @@ from controllers.common.errors import (from controllers.common.errors import (FileTooLargeError as FileTooLargeHTTPError,)+from controllers.common.errors import (+ UnsupportedFileTypeError as UnsupportedFileTypeHTTPError,+)from controllers.service_api.dataset.error import PipelineRunErrorfrom controllers.service_api.dataset.rag_pipeline import rag_pipeline_workflow as workflow_modulefrom controllers.service_api.dataset.rag_pipeline.rag_pipeline_workflow import (@@ -796,6 +799,39 @@ class TestFileUploadApiPost:assert exc_info.value.error_code == "file_too_large"mock_get_limit.assert_called_once_with("tenant-1")+ @patch("controllers.service_api.dataset.rag_pipeline.rag_pipeline_workflow.FileService")+ @patch(+ "controllers.service_api.dataset.rag_pipeline.rag_pipeline_workflow.current_user",+ new_callable=lambda: Account(name="Upload User", email="[email protected]"),+ )+ def test_upload_unsupported_file_type_returns_http_415(+ self, current_account, mock_file_svc_cls, app: Flask, sqlite_engine+ ):+ # Regression: the service error once shadowed the HTTP error of the same name,+ # so this surfaced as a 400 `invalid_param` instead of the documented 415.+ mock_file_svc_cls.return_value.upload_file.side_effect = UnsupportedFileTypeError()+ file_data = FileStorage(+ stream=io.BytesIO(b"binary"),+ filename="doc.exe",+ content_type="application/octet-stream",+ )++ with (+ patch.object(workflow_module, "db", SimpleNamespace(engine=sqlite_engine)),+ patch.object(workflow_module.FeatureService, "get_knowledge_file_size_limit", return_value=15),+ app.test_request_context(+ "/datasets/pipeline/file-upload",+ method="POST",+ content_type="multipart/form-data",+ data={"file": file_data},+ ),+ ):+ with pytest.raises(UnsupportedFileTypeHTTPError) as exc_info:+ KnowledgebasePipelineFileUploadApi().post(tenant_id="tenant-1")++ assert exc_info.value.code == 415+ assert exc_info.value.error_code == "unsupported_file_type"+def test_upload_no_file(self, app: Flask):"""Test error when no file is uploaded."""with app.test_request_context(