codeant-ai-for-open-source[bot] commented on code in PR #40860:
URL: https://github.com/apache/superset/pull/40860#discussion_r3407620442


##########
superset/databases/api.py:
##########
@@ -1727,6 +1727,7 @@ def upload_metadata(self) -> Response:
             parameters = UploadFileMetadataPostSchema().load(request_form)
         except ValidationError as error:
             return self.response_400(message=error.messages)
+        UploadCommand.validate_file_size(parameters["file"])

Review Comment:
   **Suggestion:** This call introduces a new `413` failure mode in the 
endpoint, but the route's documented responses still only list 400/401/404/500, 
so generated clients and API consumers will have an out-of-sync contract. 
Update the OpenAPI response spec for this endpoint (and upload endpoint 
consistency if needed) to include `413`. [api mismatch]
   
   <details>
   <summary><b>Severity Level:</b> Major ⚠️</summary>
   
   ```mdx
   - ⚠️ Upload metadata endpoint returns undocumented 413 status.
   - ⚠️ OpenAPI contract for upload_metadata is now inaccurate.
   ```
   </details>
   <details>
   <summary><b>Steps of Reproduction ✅ </b></summary>
   
   ```mdx
   1. Locate the `upload_metadata` endpoint in 
`superset/databases/api.py:1694-1760`; its
   OpenAPI-style docstring (lines 16-43 of that block) documents responses for 
200, 400, 401,
   404, and 500 only, with no mention of 413.
   
   2. Observe the new line added in this PR at `superset/databases/api.py:1730`:
   `UploadCommand.validate_file_size(parameters["file"])`, which can raise
   `DatabaseUploadFileTooLarge`.
   
   3. Inspect `DatabaseUploadFileTooLarge` in
   `superset/commands/database/exceptions.py:42-44`, where `status = 413` and 
the message
   "Database upload file exceeds the maximum allowed size." are defined, and 
confirm via the
   unit test `test_metadata_file_too_large` in 
`tests/unit_tests/databases/api_test.py:2-21`
   that a POST to `/api/v1/database/upload_metadata/` with an oversized file 
returns HTTP
   413.
   
   4. Compare the documented responses in the `upload_metadata` docstring (no 
413 listed)
   with the observed behavior (413 on oversized files), demonstrating that the 
endpoint now
   returns an undocumented HTTP 413 status, creating an OpenAPI / contract 
mismatch for
   clients relying on the documented response codes.
   ```
   </details>
   
   [Fix in 
Cursor](https://app.codeant.ai/fix-in-ide?tool=cursor&prompt_id=40636000552944cd9f343e74c77a4be2&service=github&base_url=https%3A%2F%2Fgithub.com&org=apache&repo=apache%2Fsuperset)
 | [Fix in VSCode 
Claude](https://app.codeant.ai/fix-in-ide?tool=vscode-claude&prompt_id=40636000552944cd9f343e74c77a4be2&service=github&base_url=https%3A%2F%2Fgithub.com&org=apache&repo=apache%2Fsuperset)
   
   *(Use Cmd/Ctrl + Click for best experience)*
   <details>
   <summary><b>Prompt for AI Agent 🤖 </b></summary>
   
   ```mdx
   This is a comment left during a code review.
   
   **Path:** superset/databases/api.py
   **Line:** 1730:1730
   **Comment:**
        *Api Mismatch: This call introduces a new `413` failure mode in the 
endpoint, but the route's documented responses still only list 400/401/404/500, 
so generated clients and API consumers will have an out-of-sync contract. 
Update the OpenAPI response spec for this endpoint (and upload endpoint 
consistency if needed) to include `413`.
   
   Validate the correctness of the flagged issue. If correct, How can I resolve 
this? If you propose a fix, implement it and please make it concise.
   Once fix is implemented, also check other comments on the same PR, and ask 
user if the user wants to fix the rest of the comments as well. if said yes, 
then fetch all the comments validate the correctness and implement a minimal fix
   ```
   </details>
   <a 
href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F40860&comment_hash=0370b45251b5fa7fa90081b576bf445d672c0aca4c153389e209bf3fb15cd1a4&reaction=like'>👍</a>
 | <a 
href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F40860&comment_hash=0370b45251b5fa7fa90081b576bf445d672c0aca4c153389e209bf3fb15cd1a4&reaction=dislike'>👎</a>



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