CurtHagenlocher opened a new pull request, #544: URL: https://github.com/apache/arrow-dotnet/pull/544
This applies #535 to `maint-23.x`. It cherry-picks cleanly. ### What's changed `VariantReader.ToVariantValue`, `VariantMetadataBuilder.CollectFieldNames`, `VariantValueWriter.CopyValue` and `VariantJsonWriter.ToJson`/`WriteTo` visit every nested value. They now check the value first and throw `InvalidDataException` if it is malformed: - Objects and arrays may be nested at most 128 deep. The spec sets no limit; this is in line with other Arrow implementations and well above the 64 levels `System.Text.Json` reads by default. - The values of an object's fields must lie inside the object and must not overlap. They may still appear in any order, and with gaps between them, as the spec allows. - Array offsets must be in order and inside the array, including the single offset of an empty array. - Every primitive must fit in the space it is given. An empty object or array that omits its single offset, which the spec requires, is still accepted where it ends the value, as before. Where another value follows it, the first byte of that value is read as the offset, as the spec says. The check is internal for now. A public way to change the limit could come later. ### Testing New tests in `VariantValidatorTests` and `VariantJsonValidationTests` cover: - nesting at the limit and past it - fields that share or overlap values - values stored out of field order or with gaps between them - offsets outside the object or array, including an empty array's - an empty object without its offset followed by another value - objects with more than 32 fields - primitives in arrays and at the top level that are cut short The parquet-testing conformance vectors, all written by Spark, pass the new check. On `maint-23.x`, `Apache.Arrow.Scalars.Tests` and `Apache.Arrow.Operations.Tests` pass on net8.0, net462 and net472, and the parquet-testing conformance vectors pass with the submodule checked out. 🤖 Generated with [Claude Code](https://claude.com/claude-code) https://claude.ai/code/session_012dFdcrBz22tRjiyNwBd7VB -- 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]
