Skip to content

Preserve Matrix type metadata for empty values#1791

Merged
kevinherron merged 1 commit into
mainfrom
codex/fix-empty-matrix-datatype-id
Jul 2, 2026
Merged

Preserve Matrix type metadata for empty values#1791
kevinherron merged 1 commit into
mainfrom
codex/fix-empty-matrix-datatype-id

Conversation

@kevinherron

Copy link
Copy Markdown
Contributor

Summary

Allow zero-length structured and enumerated Matrix values to retain their declared type metadata across decode, encode, and transform paths.

  • Add explicit Matrix DataTypeId support so empty structured/enumerated matrices do not infer concrete type metadata from element 0.
  • Preserve declared DataTypeIds when constructing structured matrices in binary, JSON, XML, and dynamic codec paths.
  • Add typed Matrix transform overloads for empty matrix conversions where the transformed element type cannot be inferred from data.
  • Add regression coverage for zero-dimension structured matrix decoding and empty Matrix metadata behavior.

Key Changes

  • Matrix metadata: Matrix can now carry an explicit ExpandedNodeId for the concrete element DataType. Empty structured and enumerated arrays no longer attempt to read element 0 during DataTypeId derivation.

  • Decode paths: Structured matrix decoders pass the declared DataTypeId into Matrix construction so empty values keep the schema type known by the caller.

  • Transform paths: Matrix transformations used by XML encoding and dynamic field codecs can now provide explicit output metadata. This keeps empty transformed matrices valid without changing non-empty inference behavior.

  • JSON struct codec: Enum and structured matrices created from JSON field definitions preserve the declared DataTypeId before being passed to downstream encoders.

References

Zero-length structured and enumerated Matrix values are valid, but Matrix
previously inferred concrete type metadata from element 0. Preserve explicit
DataTypeIds through decode and transform paths so empty matrices do not crash
or lose their declared type.
@kevinherron kevinherron marked this pull request as ready for review July 2, 2026 15:17
@kevinherron kevinherron added this to the 1.1.5 milestone Jul 2, 2026
@kevinherron kevinherron merged commit 69a76c9 into main Jul 2, 2026
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant