bito-code-review[bot] commented on code in PR #40860:
URL: https://github.com/apache/superset/pull/40860#discussion_r3408963307


##########
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:
   <div>
   
   
   <div id="suggestion">
   <div id="issue"><b>Wrong response key in test assertion</b></div>
   <div id="fix">
   
   Change the test to assert `response.json['error'] == 'Database upload file 
exceeds the maximum allowed size.'`, as `json_error_response` uses the `error` 
field for string error details.
   </div>
   
   
   </div>
   
   
   
   
   <small><i>Code Review Run #c551b2</i></small>
   </div>
   
   ---
   Should Bito avoid suggestions like this for future reviews? (<a 
href=https://alpha.bito.ai/home/ai-agents/review-rules>Manage Rules</a>)
   - [ ] Yes, avoid them



##########
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:
   <div>
   
   
   <div id="suggestion">
   <div id="issue"><b>Missing Czech translation</b></div>
   <div id="fix">
   
   Add the Czech translation for the new error message by inserting:
   msgstr "Nahraný soubor překračuje maximální povolenou velikost." below the 
existing `msgid` line.
   </div>
   
   
   </div>
   
   
   
   
   <small><i>Code Review Run #c551b2</i></small>
   </div>
   
   ---
   Should Bito avoid suggestions like this for future reviews? (<a 
href=https://alpha.bito.ai/home/ai-agents/review-rules>Manage Rules</a>)
   - [ ] Yes, avoid them



-- 
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]

Reply via email to