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


##########
superset/databases/schemas.py:
##########
@@ -488,34 +510,124 @@ def validate_embedded_credentials(
                 field_name="masked_encrypted_extra",
             )
 
-        # A credential only applies to a per-user OAuth2 connection with
-        # impersonation on (`Database.embedded_fallback_applies`). Anywhere 
else
-        # it would save and silently do nothing -- or, with impersonation off,
-        # leave every viewer on the connection's own account while the setting
-        # reads as configured -- so refuse it rather than store it.
-        if (
-            engine_spec.supports_embedded_credential_fallback
-            and engine_spec.validate_embedded_credentials(credentials) is not 
None
+        impersonate_user = data.get(
+            "impersonate_user", stored.impersonate_user if stored else False
+        )
+        if not _embedded_credentials_stranded(
+            engine_spec, encrypted_extra, impersonate_user
         ):
-            impersonate_user = data.get(
-                "impersonate_user", stored.impersonate_user if stored else 
False
-            )
-            client_info = encrypted_extra.get("oauth2_client_info")
-            has_oauth2_client = bool(isinstance(client_info, dict) and 
client_info) or (
-                engine_spec.supports_oauth2
-                and engine_spec.engine_name
-                in current_app.config["DATABASE_OAUTH2_CLIENTS"]
+            return

Review Comment:
   **Suggestion:** This checks the row during schema loading; concurrent 
partial PUTs can both pass and commit a credential with impersonation off.
   
   **Assessment:** ๐ŸŸ  `Major` ยท ๐Ÿ” `Occurrence: Rarely` ยท ๐Ÿท๏ธ `Race condition`
   
   [![Use CodeAnt 
Skill](https://new-codeant-butcket.s3.us-west-1.amazonaws.com/badges/use-codeant-skill-flat-v2.svg)](https://docs.codeant.ai/cli/resolve-pr-comments-skill)
 [![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=045952bbc24d48a6891fc0af99642093&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=045952bbc24d48a6891fc0af99642093&service=github&base_url=https%3A%2F%2Fgithub.com&org=apache&repo=apache%2Fsuperset)
   <details>
   <summary><b>Prompt for AI Agent ๐Ÿค– </b></summary>
   
   ```mdx
   This is a comment left during a code review.
   
   **Path:** superset/databases/schemas.py
   **Line:** 513:519
   **Comment:**
        *Race Condition: This checks the row during schema loading; concurrent 
partial PUTs can both pass and commit a credential with impersonation off.
   
   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%2F45869&comment_hash=92c6b076fc7cdf9a412591d8e64f31d283ddb698ec41e513ac41323c5e63c7a7&reaction=like'>๐Ÿ‘</a>
 | <a 
href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F45869&comment_hash=92c6b076fc7cdf9a412591d8e64f31d283ddb698ec41e513ac41323c5e63c7a7&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