You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
JSON decoder for RunEndEncoded accepts nulls even though the values field is non-nullable #10478
The implementation for REE decoder forces the child field's decoder to accept nulls even though the Arrow schema for the values field may declare it non-nullable. As the REE encoding has no container-level null mask, this may smuggle null values into the values array that must not have them.
Furthermore, even if the REE field itself is non-nullable, the flag passed down to construct the child decoder is ignored by e.g. StringArrayDecoder. The resulting nulls are not invalidated by a post-hoc check the way StructArrayDecoder does.
To Reproduce
Repro test case:
#[test]fntest_read_run_end_encoded_nulls_in_non_nullable_values(){// A `RunArray` has no validity buffer of its own, so unlike a struct child// there is no parent-level mask that could make these nulls representable.// Declaring the enclosing field nullable does not change that.let ree_type = DataType::RunEndEncoded(Arc::new(Field::new("run_ends",DataType::Int32,false)),Arc::new(Field::new("values",DataType::Utf8,false)),);let schema = Arc::new(Schema::new(vec![Field::new("a",
ree_type,true,)]));// An explicit null, and a missing field, should be both rejected.for buf in[r#" {"a": "x"} {"a": null} {"a": "y"} "#,r#" {"a": "x"} {} {"a": "y"} "#,]{letmut decoder = ReaderBuilder::new(schema.clone()).build_decoder().unwrap();let res = decoder
.decode(buf.as_bytes()).and_then(|_| decoder.flush());assert!(res.is_err());}}
Expected behavior
The schema violation should produce an error.
Additional context
Note that this is a breaking change, since the current implementation may tolerate nullable inputs, even if they produce non-compliant outputs.
I'd like to pick this up, with one question on the intended shape of the fix.
My reading of RunEndEncodedArrayDecoder::new:
let decoder = ctx.make_decoder(
values_field.data_type(),
values_field.is_nullable() || is_nullable,)?;
The || is_nullable is the part that doesn't hold up. A RunArray has no container-level validity buffer, so an outer "this REE field is nullable" can't be represented at the REE level — propagating it downward silently relaxes the values field's own nullability, which is exactly the smuggling you describe. values_field.is_nullable() alone looks like the correct capability to hand the child.
That covers the first half. The second half you raise is the part I'd rather not guess at: even with the flag correctly false, decoders like StringArrayDecoder ignore it, so nothing actually rejects a null that arrives from the tape — whereas StructArrayDecoder catches it after the fact. So dropping || is_nullable alone would fix the schema-propagation bug but still let a literal null in the JSON land in a non-nullable values array.
Which would you prefer?
Minimal — drop || is_nullable so the child decoder gets the values field's declared nullability, and add your repro as a regression test. Leaves the "decoder ignores the flag" gap open as a separate concern.
Also validate in the REE decoder — additionally check the decoded values array for nulls when values_field.is_nullable() is false and error out, mirroring the post-hoc approach in StructArrayDecoder.
Fix it at the child-decoder level — make the primitive/string decoders honour the flag they're given. Broader blast radius and presumably affects more than REE, so I'd assume you'd want that separately.
I'd lean towards (2) as the self-contained fix, but this is your codebase's convention rather than mine to set. Happy to start as soon as you point me at one — and if someone else is already on it, no problem at all.
#10485 is an open PR to fix this (so I held off on submitting my own), but it seems to have stalled after the initial review. Check the discussion there and feel free to pick it up. It's good if you are able to participate as a human and respond to feedback.
Activity
minutechreview commentedon Aug 12, 2026
I'd like to pick this up, with one question on the intended shape of the fix.
My reading of
RunEndEncodedArrayDecoder::new:The
|| is_nullableis the part that doesn't hold up. ARunArrayhas no container-level validity buffer, so an outer "this REE field is nullable" can't be represented at the REE level — propagating it downward silently relaxes the values field's own nullability, which is exactly the smuggling you describe.values_field.is_nullable()alone looks like the correct capability to hand the child.That covers the first half. The second half you raise is the part I'd rather not guess at: even with the flag correctly
false, decoders likeStringArrayDecoderignore it, so nothing actually rejects a null that arrives from the tape — whereasStructArrayDecodercatches it after the fact. So dropping|| is_nullablealone would fix the schema-propagation bug but still let a literalnullin the JSON land in a non-nullable values array.Which would you prefer?
|| is_nullableso the child decoder gets the values field's declared nullability, and add your repro as a regression test. Leaves the "decoder ignores the flag" gap open as a separate concern.values_field.is_nullable()is false and error out, mirroring the post-hoc approach inStructArrayDecoder.I'd lean towards (2) as the self-contained fix, but this is your codebase's convention rather than mine to set. Happy to start as soon as you point me at one — and if someone else is already on it, no problem at all.
mzabaluev commentedon Aug 12, 2026
#10485 is an open PR to fix this (so I held off on submitting my own), but it seems to have stalled after the initial review. Check the discussion there and feel free to pick it up. It's good if you are able to participate as a human and respond to feedback.
fix(arrow-json): validate REE nullability (#10749)
fix(arrow-json): validate REE nullability (apache#10749)
fix(arrow-json): validate REE nullability (apache#10749)
fix(arrow-json): validate REE nullability (apache#10749)
fix(arrow-json): validate REE nullability (apache#10749)
fix(arrow-json): validate REE nullability (apache#10749)
fix(arrow-json): validate REE nullability (apache#10749)