fix: accept null optional nested metadata during rehydration

AF
13h ago
+142-0

Summary

Serialized elements can contain explicit null values for optional metadata. Ordinary fields already treat these values as unset, but ElementMetadata.from_dict() unconditionally invokes nested decoders for coordinates, data_source, orig_elements, and key_value_pairs. A null in any of those fields therefore raises an exception and prevents the document from being rehydrated by the dict, JSON, and NDJSON entry points.

Skip unset field values before dispatching to the nested decoders. Explicit nulls now behave like omitted fields; populated nested metadata still uses the existing decoder, and malformed non-null values still raise.

Validation

  • 26 regression/control cases exercise dict staging, JSON and NDJSON text/file/filename inputs, all four optional nested fields, combinations of null and populated siblings, input preservation, malformed nested values, and other falsey values such as zero, false, and an empty string.
  • Base revision: 21 failed, 5 passed. After the fix, the new cases plus the existing element suite report 108 passed with normal package imports on Python 3.12.14.
  • Ruff 0.17.5 check, format --check, and git diff --check pass. The full repository and partition suites were not run.

Checklist

  • The PR title is a user-facing release-note entry with a conventional commit prefix.
  • Apply a category label (enhancement, bug, or an appropriate existing label), or ask a maintainer to apply it. Please apply bug.
  • For breaking changes, use ! in the title and explain impact and migration above. No breaking API change.