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


##########
superset/db_engine_specs/duckdb.py:
##########
@@ -369,6 +369,38 @@ def get_extra_params(
 
         return extra
 
+    @classmethod
+    def impersonate_user(
+        cls,
+        database: Database,
+        username: str | None,
+        user_token: str | None,
+        url: URL,
+        engine_kwargs: dict[str, Any],
+    ) -> tuple[URL, dict[str, Any]]:
+        # Local DuckDB has no user concept, and the base implementation's
+        # username-in-URL is passed by duckdb-engine as a connect() kwarg
+        # that duckdb rejects -- so never call it. Note that md: databases
+        # also resolve to this spec (spec lookup is by backend name only,
+        # and MotherDuck shares the duckdb:// scheme).
+        if username is None or not (url.database or "").startswith("md:"):
+            return url, engine_kwargs

Review Comment:
   **Suggestion:** The early return avoids the base implementation, but it 
leaves any existing `url.username` untouched. A MotherDuck URL configured with 
a username therefore still passes that username through the DuckDB dialect as a 
connection argument, defeating the stated purpose of bypassing username-based 
impersonation and causing connection failure. Clear the URL username for 
DuckDB/MotherDuck before returning or constructing the modified URL. [api 
mismatch]
   
   <details>
   <summary><b>Severity Level:</b> Major ⚠️</summary>
   
   ```mdx
   - ❌ User-impersonated MotherDuck connections with URL usernames can fail.
   - ⚠️ Existing database credentials may remain passed to DuckDB.
   ```
   </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=3f406c80033e4c518dd899f186b37c6a&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=3f406c80033e4c518dd899f186b37c6a&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/db_engine_specs/duckdb.py
   **Line:** 386:387
   **Comment:**
        *Api Mismatch: The early return avoids the base implementation, but it 
leaves any existing `url.username` untouched. A MotherDuck URL configured with 
a username therefore still passes that username through the DuckDB dialect as a 
connection argument, defeating the stated purpose of bypassing username-based 
impersonation and causing connection failure. Clear the URL username for 
DuckDB/MotherDuck before returning or constructing the modified URL.
   
   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%2F42705&comment_hash=61e394a7e6733c17bcf975f3b4a86029c623e727c09d1d33ea2b1cd76c9ce6d9&reaction=like'>👍</a>
 | <a 
href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F42705&comment_hash=61e394a7e6733c17bcf975f3b4a86029c623e727c09d1d33ea2b1cd76c9ce6d9&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