FrancescoCastaldi opened a new pull request, #45820: URL: https://github.com/apache/superset/pull/45820
### Summary Extension Storage values written with encrypt=True failed to be read back, raising TypeError: string argument without an encoding and logging decryption failure. _enc_type() in superset/extensions/storage/persistent_dao.py wraps the payload in EncryptedType(LargeBinary, ...). The underlying encryption engines in sqlalchemy_utils (AesEngine, AesGcmEngine) operate on text. When receiving raw ytes, they encrypt epr(value), and during process_result_value(), StringEncryptedType converts the decrypted string using underlying_type.python_type(decrypted), calling ytes(str) which raises TypeError. This PR enhances EncryptedType in superset/utils/encrypt.py to natively support binary underlying types (LargeBinary / ytes): 1. **On write (process_bind_param)**: Base64-encodes binary payloads into clean ASCII text before passing to the encryption engine. 2. **On read (process_result_value)**: Decodes the decrypted base64 text back into original raw bytes. 3. Added comprehensive unit tests in ests/unit_tests/utils/encrypt_test.py and ests/unit_tests/extensions/storage/test_persistent_dao.py covering AES-CBC and AES-GCM round-trips with arbitrary binary payloads, empty bytes, and user-scoped ciphertext. Fixes #45787. ### Testing Instructions - pytest tests/unit_tests/utils/encrypt_test.py -k large_binary - pytest tests/unit_tests/extensions/storage/test_persistent_dao.py -k encryption -- 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]
