Add proptest fuzzing to parquet-variant and implement fixes for findings - #10352
Add proptest fuzzing to parquet-variant and implement fixes for findings#10352cetra3 wants to merge 3 commits into
proptest fuzzing to parquet-variant and implement fixes for findings#10352Conversation
| use std::collections::HashSet; | ||
|
|
||
| /// The empty metadata dictionary. | ||
| const EMPTY_METADATA: &[u8] = &[1, 0, 0]; |
There was a problem hiding this comment.
we can reuse the EMPTY_VARIANT_METADATA_BYTES in variant/metdata.rs
| } | ||
| } else { | ||
| // The metadata dictionary can't guarantee uniqueness or sortedness, so we have to parse out the corresponding field names | ||
| // to check lexicographical order |
There was a problem hiding this comment.
Do we need to update the doc here to respect the uniqueness?
| let mut current_offset = offsets.next().unwrap_or(0); | ||
| for next_offset in offsets { | ||
| value_buffer | ||
| .get(current_offset..next_offset) |
There was a problem hiding this comment.
I'm curious about the cause of the offset not land on UTF-8 character boundaries. is the data corrupt or the writer did not write the right data?
There was a problem hiding this comment.
Yeah this is to guard against corrupt data. I don't think there is a way to construct this shape of data with VariantBuilder but you can easily craft corrupted bytes that will hit a panic.
This is the same check as the other branch makes a handful of lines above, so nothing new here.
7cb043d to
546b20e
Compare
| return Err(ArrowError::InvalidArgumentError( | ||
| "offsets not monotonically increasing".to_string(), | ||
| )); | ||
| // Slicing each dictionary value validates that offsets are in-bounds, non-decreasing, |
There was a problem hiding this comment.
small nit: original comment was correct in calling it monotonically increasing, as monotonically increasing allows either staying flat or going up. strict monotonically increasing is when its only going up (can't stay flat)
|
@cetra3 would you be able to merge up from main here |
546b20e to
6f9372f
Compare
- Hoist shared `current_offset` initialization out of the sorted/unsorted branches in metadata validation (branches_sharing_code) - Parenthesize shift in proptest metadata header construction (precedence_bits) Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Which issue does this PR close?
This PR is not tied to a single pre-existing issue; it fixes findings 1-6 in the table below,
all found while adding the
proptestharness. The two remaining findings are out of scope hereand are tracked as follow-up issues:
shred_variantpanics on an object with duplicate field names (finding 7)PartialEqon unvalidated deeply-nested variants overflows the stack (finding 8)Here's a list of bugs found:
metadata.rs:317metadata.rs(same branch)object.rs:270decode_dateoverflows on large day countsdecoder.rs:281try_newdecode_uuidindexes raw on a truncated payloaddecoder.rs:347try_newlist.rs:234,object.rsshred_variantdouble-appends on duplicate field namesshred_variant.rs:418-429PartialEqrecurses without bound on shallow variantslist.rs:313,object.rsRationale for this change
This PR was raised after some bugs caught in production caused some failing jobs.
The original bug was empty field strings caused a weird
offsets not monotonically increasing, but with the assistance of an agent, we expanded our search to useproptestto find some other similar cases.What changes are included in this PR?
Adds a new
proptestharness forparquet-variantand fixesAre these changes tested?
Yes, most of these changes are driven by failing proptests and converted into smaller unit tests.
Are there any user-facing changes?
The only one that is probably worth mentioning, and maybe something we allow to be configured, is a max depth recursion constant was added.