diff --git a/superset/config.py b/superset/config.py index 02b0d7ef3c6..7c1436bb505 100644 --- a/superset/config.py +++ b/superset/config.py @@ -849,9 +849,6 @@ CSV_EXTENSIONS = {"csv", "tsv", "txt"} COLUMNAR_EXTENSIONS = {"parquet", "zip"} ALLOWED_EXTENSIONS = {*EXCEL_EXTENSIONS, *CSV_EXTENSIONS, *COLUMNAR_EXTENSIONS} -# Optional maximum file size in bytes when uploading a CSV -CSV_UPLOAD_MAX_SIZE = None - # CSV Options: key/value pairs that will be passed as argument to DataFrame.to_csv # method. # note: index option should not be overridden diff --git a/superset/databases/schemas.py b/superset/databases/schemas.py index 0c821a6f34d..66366d95199 100644 --- a/superset/databases/schemas.py +++ b/superset/databases/schemas.py @@ -20,7 +20,6 @@ from __future__ import annotations import inspect -import os from pathlib import Path from typing import Any, TypedDict @@ -1234,16 +1233,6 @@ class CSVUploadPostSchema(BaseUploadPostSchema): ) from ex return data - @validates("file") - def validate_file_size(self, file: FileStorage) -> None: - file.flush() - size = os.fstat(file.fileno()).st_size - if ( - current_app.config["CSV_UPLOAD_MAX_SIZE"] is not None - and size > current_app.config["CSV_UPLOAD_MAX_SIZE"] - ): - raise ValidationError([_("File size exceeds the maximum allowed size.")]) - class ExcelUploadPostSchema(BaseUploadPostSchema): """ diff --git a/tests/unit_tests/databases/api_test.py b/tests/unit_tests/databases/api_test.py index e24580cb8ac..be835cb8778 100644 --- a/tests/unit_tests/databases/api_test.py +++ b/tests/unit_tests/databases/api_test.py @@ -1090,32 +1090,6 @@ def test_csv_upload_validation( assert response.json == expected_response -def test_csv_upload_file_size_validation( - mocker: MockerFixture, - client: Any, - full_api_access: None, -) -> None: - """ - Test CSV Upload validation fails. - """ - _ = mocker.patch.object(UploadCommand, "run") - current_app.config["CSV_UPLOAD_MAX_SIZE"] = 5 - response = client.post( - "/api/v1/database/1/csv_upload/", - data={ - "file": (create_csv_file(), "out.csv"), - "table_name": "table1", - "delimiter": ",", - }, - content_type="multipart/form-data", - ) - assert response.status_code == 400 - assert response.json == { - "message": {"file": ["File size exceeds the maximum allowed size."]} - } - current_app.config["CSV_UPLOAD_MAX_SIZE"] = None - - @pytest.mark.parametrize( "filename", [