Skip to content

Commit

Permalink
refactor: Remove CSV upload size limit and related validation (apache…
Browse files Browse the repository at this point in the history
  • Loading branch information
sha174n authored and sfirke committed Feb 12, 2025
1 parent a96ce00 commit 6dea729
Show file tree
Hide file tree
Showing 3 changed files with 0 additions and 40 deletions.
3 changes: 0 additions & 3 deletions superset/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -849,9 +849,6 @@ class D3TimeFormat(TypedDict, total=False):
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
Expand Down
11 changes: 0 additions & 11 deletions superset/databases/schemas.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
from __future__ import annotations

import inspect
import os
from pathlib import Path
from typing import Any, TypedDict

Expand Down Expand Up @@ -1234,16 +1233,6 @@ def convert_column_data_types(
) 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):
"""
Expand Down
26 changes: 0 additions & 26 deletions tests/unit_tests/databases/api_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -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",
[
Expand Down

0 comments on commit 6dea729

Please # to comment.