Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Return error instead of panic when reading invalid Parquet metadata #5382

Merged
merged 3 commits into from
Feb 11, 2024

Conversation

mmaitre314
Copy link
Contributor

Which issue does this PR close?

Closes #3279.

Rationale for this change

The Parquet crate typically returns errors instead of panics when reading invalid files. There was a panic left in the code generated by the Thrift compiler, which this PR addresses.

What changes are included in this PR?

I hit issues running regen.sh on WSL2: it looks like only the pacman command was run inside the archlinux container and the following commands were run outside of it. Not 100% sure, but wrapping all the command instead a bash command string fixed the issue for me.

Are there any user-facing changes?

SerializedFileReader::new() returns errors when it used to panic.

@github-actions github-actions bot added the parquet Changes to the parquet crate label Feb 10, 2024
Copy link
Contributor

@alamb alamb 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 @mmaitre314 -- this looks good to me. We appreciate the contribution

let ret = SerializedFileReader::new(Bytes::copy_from_slice(&data));
assert_eq!(
ret.err().unwrap().to_string(),
"Parquet error: Could not parse metadata: bad data"
Copy link
Contributor

Choose a reason for hiding this comment

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

It is unfortunate that this error message isn't more specific about what part of the file is bad, but I don't think this PR makes it any better or worse

I ran this test without the changes in this PR and it paniced:

     Running unittests src/lib.rs (target/debug/deps/parquet-94528dc13c197da2)

return value should have been constructed
thread 'file::serialized_reader::tests::test_file_reader_invalid_metadata' panicked at parquet/src/format.rs:4303:14:
return value should have been constructed

@tustvold tustvold merged commit 9d0abcc into apache:master Feb 11, 2024
16 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
parquet Changes to the parquet crate
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Panic in parquet::file::footer::decode_metadata
4 participants