codeant-ai-for-open-source[bot] commented on code in PR #45788:
URL: https://github.com/apache/superset/pull/45788#discussion_r4389258987
##########
superset/extensions/storage/persistent_dao.py:
##########
@@ -47,6 +50,42 @@
logger = logging.getLogger(__name__)
+class EncryptedBytesType(EncryptedType):
+ """EncryptedType that round-trips arbitrary bytes.
+
+ The sqlalchemy_utils engines encrypt text. Given ``bytes``, the parent
+ class encrypts ``repr(value)`` and then fails to rebuild ``bytes`` from
+ the decrypted string ("string argument without an encoding"), so nothing
+ written with ``encrypt=True`` could be read back. The payload is
+ base64-encoded before encryption and decoded after decryption instead.
+ """
+
+ cache_ok = True
+
+ def process_bind_param(self, value: bytes | None, dialect: Any) -> Any:
+ if value is None:
+ return None
+ return super().process_bind_param(
+ base64.b64encode(value).decode("ascii"), dialect
Review Comment:
**Suggestion:** New ciphertext contains base64 text, but `SecretsMigrator`
decrypts it with plain `EncryptedType(LargeBinary)`, causing string-to-bytes
conversion to fail and the migration transaction to roll back.
**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=318de1c44fdc4e48aa63d1ea1addc18b&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=318de1c44fdc4e48aa63d1ea1addc18b&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/extensions/storage/persistent_dao.py
**Line:** 68:69
**Comment:**
*Api Mismatch: New ciphertext contains base64 text, but
`SecretsMigrator` decrypts it with plain `EncryptedType(LargeBinary)`, causing
string-to-bytes conversion to fail and the migration transaction to roll back.
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%2F45788&comment_hash=bee903bf9b396fdab4833700fb143227510e0750f5ac03f696756210e97a289d&reaction=like'>๐</a>
| <a
href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F45788&comment_hash=bee903bf9b396fdab4833700fb143227510e0750f5ac03f696756210e97a289d&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]