rusackas commented on code in PR #40860:
URL: https://github.com/apache/superset/pull/40860#discussion_r3409023463
##########
superset/translations/cs/LC_MESSAGES/messages.po:
##########
@@ -4633,6 +4633,9 @@ msgstr "Nastavení databáze aktualizováno"
msgid "Database type does not support file uploads."
msgstr "Typ databáze nepodporuje nahrávání souborů."
+msgid "Database upload file exceeds the maximum allowed size."
+msgstr ""
Review Comment:
These `.po` files get regenerated from the `.pot` template, so hand-adding a
`msgstr` here would just get overwritten. Empty for new strings is expected.
##########
tests/unit_tests/databases/api_test.py:
##########
@@ -1858,6 +1858,43 @@ def test_columnar_metadata_validation(
assert response.json == {"message": {"file": ["Field may not be null."]}}
+def test_metadata_file_too_large(
+ mocker: MockerFixture, client: Any, full_api_access: None
+) -> None:
+ """
+ The metadata endpoint rejects an oversized file with a 413 before the
+ reader parses it, so the size limit cannot be bypassed by hitting
+ ``upload_metadata`` instead of ``upload``.
+ """
+ file_metadata = mocker.patch.object(CSVReader, "file_metadata")
+ mocker.patch.dict(current_app.config, {"UPLOAD_MAX_FILE_SIZE_BYTES": 4})
+ response = client.post(
+ "/api/v1/database/upload_metadata/",
+ data={"type": "csv", "file": create_csv_file()},
+ content_type="multipart/form-data",
+ )
+ assert response.status_code == 413
+ assert (
+ response.json["errors"][0]["message"]
+ == "Database upload file exceeds the maximum allowed size."
+ )
Review Comment:
`DatabaseUploadFileTooLarge` is a `CommandException` raised through
`@handle_api_exception`, not `json_error_response`, so the payload is the
`errors[]` array, not an `error` key. The assertion is correct as-is.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]