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


##########
superset/commands/database/uploaders/base.py:
##########
@@ -261,10 +261,28 @@ def validate_file_size(cls, file: Any) -> None:
         if size is not None and size > max_file_size:
             raise DatabaseUploadFileTooLarge()
 
+    @staticmethod
+    def _resolve_default_schema(database: Database) -> Optional[str]:
+        """Resolve the database's default schema so uploaded datasets carry an
+        explicit schema instead of NULL, which would otherwise duplicate an
+        existing dataset over the same table (see #36305)."""
+        try:
+            return database.get_default_schema(database.get_default_catalog())
+        except Exception:  # pylint: disable=broad-except
+            # Resolution opens an inspector connection; a failure here must
+            # degrade to the no-schema behavior rather than fail the upload.
+            logger.warning(
+                "Unable to resolve default schema for upload; proceeding 
without one",
+                exc_info=True,
+            )
+            return None
+
     def validate(self) -> None:
         self._model = DatabaseDAO.find_by_id(self._model_id)
         if not self._model:
             raise DatabaseNotFoundError()
+        if not self._schema:
+            self._schema = self._resolve_default_schema(self._model)

Review Comment:
   **Suggestion:** The resolved schema is passed to `schema_allows_file_upload` 
using exact, case-sensitive matching, while schema discovery and the UI 
allow-list handling normalize names case-insensitively. For engines that report 
a default schema such as `PUBLIC` while the configured allow-list contains 
`public`, uploads without an explicit schema are incorrectly rejected. 
Normalize the resolved schema and allow-list comparison consistently before 
performing the authorization check. [api mismatch]
   
   <details>
   <summary><b>Severity Level:</b> Major ⚠️</summary>
   
   ```mdx
   - ❌ Valid default-schema uploads are rejected.
   - ⚠️ Behavior depends on engine schema casing.
   - ⚠️ Allow-list configuration becomes case-sensitive unexpectedly.
   ```
   </details>
   
   [![Fix in 
Cursor](https://new-codeant-butcket.s3.us-west-1.amazonaws.com/badges/fix-in-cursor-flat.svg)](https://app.codeant.ai/fix-in-ide?tool=cursor&prompt_id=b98c4a42a8bc411aa0e7eb5ffb541b96&service=github&base_url=https%3A%2F%2Fgithub.com&org=apache&repo=apache%2Fsuperset)
 [![Fix in VSCode 
Claude](https://new-codeant-butcket.s3.us-west-1.amazonaws.com/badges/fix-in-vscode-claude-flat.svg)](https://app.codeant.ai/fix-in-ide?tool=vscode-claude&prompt_id=b98c4a42a8bc411aa0e7eb5ffb541b96&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/commands/database/uploaders/base.py
   **Line:** 284:285
   **Comment:**
        *Api Mismatch: The resolved schema is passed to 
`schema_allows_file_upload` using exact, case-sensitive matching, while schema 
discovery and the UI allow-list handling normalize names case-insensitively. 
For engines that report a default schema such as `PUBLIC` while the configured 
allow-list contains `public`, uploads without an explicit schema are 
incorrectly rejected. Normalize the resolved schema and allow-list comparison 
consistently before performing the authorization check.
   
   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%2F42603&comment_hash=adcb074c8f0b274f0f9bafaf8b0249aa1bb90a8b0d39a2970fb0670eada25cfb&reaction=like'>👍</a>
 | <a 
href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F42603&comment_hash=adcb074c8f0b274f0f9bafaf8b0249aa1bb90a8b0d39a2970fb0670eada25cfb&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