Skip to content

feat: Making From<ConfigFileDecryptionProperties/ConfigFileEncryptionProperties> conversions fallible with TryFrom#21985

Open
Soham-Bhattacharjee-work wants to merge 3 commits intoapache:mainfrom
Soham-Bhattacharjee-work:from-to-try_from-for-ConfigEncryptionDecryption
Open

feat: Making From<ConfigFileDecryptionProperties/ConfigFileEncryptionProperties> conversions fallible with TryFrom#21985
Soham-Bhattacharjee-work wants to merge 3 commits intoapache:mainfrom
Soham-Bhattacharjee-work:from-to-try_from-for-ConfigEncryptionDecryption

Conversation

@Soham-Bhattacharjee-work
Copy link
Copy Markdown

Which issue does this PR close?

Rationale for this change

The conversions from ConfigFileDecryptionProperties to FileDecryptionProperties and from ConfigFileEncryptionProperties to FileEncryptionProperties currently use From, but the implementations contain several unwrap() and expect() calls which can cause panics for invalid or wrong inputs. Instead of panics we can gracefully return DataFusionError::Confoguration errors.

What changes are included in this PR?

impl From<ConfigFileEncryptionProperties> for FileEncryptionProperties

becomes

impl TryFrom<ConfigFileEncryptionProperties> for FileEncryptionProperties

Similarly

impl From<ConfigFileDecryptionProperties> for FileDecryptionProperties

becomes

impl TryFrom<ConfigFileDecryptionProperties> for FileDecryptionProperties

These are header changes with accompanied implementation changes

Are these changes tested?

Yes tests are added in datafusion/common/src/config.rs

Are there any user-facing changes?

No according to me, they are not. They are part of datafusion-common.

@github-actions github-actions Bot added common Related to common crate datasource Changes to the datasource crate labels May 2, 2026
@Soham-Bhattacharjee-work Soham-Bhattacharjee-work changed the title Making From<ConfigFileDecryptionProperties/ConfigFileEncryptionProperties> conversions fallible with TryFrom feat: Making From<ConfigFileDecryptionProperties/ConfigFileEncryptionProperties> conversions fallible with TryFrom May 2, 2026
Copy link
Copy Markdown
Contributor

@kumarUjjawal kumarUjjawal left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you @Soham-Bhattacharjee-work I have left some comments, also can you update the pr body that this is user facing change since it is API breaking

let encryption_key = hex::decode(&encryption_props.column_key_as_hex)
.expect("Invalid column encryption key");
.map_err(|e| {
DataFusionError::Configuration(format!("Unable to decode hex encryption key metadata for column {column_name}: {e}"))
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

message says "encryption key metadata", but this is decoding the actual column encryption key. Please change it.

#[cfg(feature = "parquet_encryption")]
impl From<ConfigFileEncryptionProperties> for FileEncryptionProperties {
fn from(val: ConfigFileEncryptionProperties) -> Self {
impl TryFrom<ConfigFileEncryptionProperties> for FileEncryptionProperties {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we need entry in upgrade guide.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

common Related to common crate datasource Changes to the datasource crate

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Make From<ConfigFileDecryptionProperties>/ConfigFileEncryptionProperties conversions fallible (TryFrom)

2 participants