codeant-ai-for-open-source[bot] commented on code in PR #45890:
URL: https://github.com/apache/superset/pull/45890#discussion_r4423714198
##########
superset/databases/schemas.py:
##########
@@ -1146,25 +1236,37 @@ def validate_masked_encrypted_extra(
"File contains both `encrypted_extra` and
`masked_encrypted_extra`"
)
- if db.session.query(Database).filter_by(uuid=data["uuid"]).first():
- # Existing DB: sensitive values will be revealed from existing
- # encrypted_extra in import_database()
- return
-
masked_encrypted_extra = json.loads(data["masked_encrypted_extra"])
- # Determine engine spec from sqlalchemy_uri to get sensitive fields
- sqlalchemy_uri = data["sqlalchemy_uri"]
- url = make_url_safe(sqlalchemy_uri)
- backend = url.get_backend_name()
- driver = url.get_driver_name()
- db_engine_spec = get_engine_spec(backend, driver=driver)
-
- # Check if any sensitive field is still masked
- masked_fields = get_masked_fields(
- masked_encrypted_extra,
- db_engine_spec.encrypted_extra_sensitive_field_paths(),
- )
+ if existing :=
db.session.query(Database).filter_by(uuid=data["uuid"]).first():
+ if not self.overwrites_existing:
+ return
+ # Existing DB: masked values are revealed from its stored
+ # encrypted_extra in import_database(). Any the stored payload has
no
+ # value for -- e.g. a connection promoted without its OAuth2
client or
+ # embedded credential -- would otherwise be stored as the mask
itself,
+ # so ask for those like a new DB.
+ db_engine_spec = existing.db_engine_spec
+ masked_fields = json.unrevealable_masked_fields(
+ json.loads(existing.encrypted_extra)
+ if existing.encrypted_extra
+ else None,
+ masked_encrypted_extra,
+ db_engine_spec.encrypted_extra_sensitive_field_paths(),
Review Comment:
**Suggestion:** When an overwrite changes the URI, this treats an old secret
as reusable even though `import_database()` refuses reuse; validation passes,
then import fails instead of requesting the secret.
**Assessment:** ๐ `Major` ยท ๐ `Occurrence: Rarely` ยท ๐ท๏ธ `Api mismatch`
[](https://docs.codeant.ai/cli/resolve-pr-comments-skill)
[](https://app.codeant.ai/fix-in-ide?tool=cursor&prompt_id=6431d7f1b4d3401b8d7607a4386d5d26&service=github&base_url=https%3A%2F%2Fgithub.com&org=apache&repo=apache%2Fsuperset)
[](https://app.codeant.ai/fix-in-ide?tool=vscode-claude&prompt_id=6431d7f1b4d3401b8d7607a4386d5d26&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:** 1249:1255
**Comment:**
*Api Mismatch: When an overwrite changes the URI, this treats an old
secret as reusable even though `import_database()` refuses reuse; validation
passes, then import fails instead of requesting the secret.
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%2F45890&comment_hash=4a654ba825c9b4d4b8c6b11a9d390b260048d59098eb8af7eda7dbfc8140101c&reaction=like'>๐</a>
| <a
href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F45890&comment_hash=4a654ba825c9b4d4b8c6b11a9d390b260048d59098eb8af7eda7dbfc8140101c&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]