Skip to content

Ensure that nested objects are deserialized in the order of serialization - #4874

Open
robert-brunel wants to merge 1 commit into
mainfrom
apple/robert-brunel/fix-proto-read-order
Open

robert-brunel wants to merge 1 commit into
mainfrom
apple/robert-brunel/fix-proto-read-order

Conversation

@robert-brunel

Copy link
Copy Markdown
Contributor

This change fixes incorrect fromProto() methods that were reading nested objects in a different order than toProto() writes them. The incorrect order could lead to internal errors (VerifyException) during deserialization. During serialization, a record type is serialized in full only at the point of its first occurrence; later occurrences of the type then just refer to the previous occurrence through a reference id. Reading nested objects out of order can cause such a reference to be reached before the actual definition.

The affected types are:

  • PickValue
  • RecordQueryScoreForRankPlan and ScoreForRank
  • RecordQueryInUnionPlan
  • RecordQueryAggregateIndexPlan
  • UserDefinedMacroFunction
  • MultidimensionalIndexScanComparisons
  • RangeConstraints
  • PromoteValue.ArrayCoercionBiFunction

The PickValue case is covered end-to-end by the new CASE queries in skipped-field-number-proto.yamsql.

Fixes #4873.

@robert-brunel robert-brunel added the bug fix Change that fixes a bug label Nov 10, 2026
@robert-brunel robert-brunel self-assigned this Nov 10, 2026
@robert-brunel
robert-brunel force-pushed the apple/robert-brunel/fix-proto-read-order branch from 35ca628 to c1279c5 Compare November 10, 2026 18:23
…tion

This change fixes incorrect `fromProto()` methods that were reading nested objects in a different order than `toProto()` writes them. The incorrect order could lead to internal errors (`VerifyException`) during deserialization. During serialization, a record type is serialized in full only at the point of its first occurrence; later occurrences of the type then just refer to the previous occurrence through a reference id. Reading nested objects out of order can cause such a reference to be reached before the actual definition.

The affected types are:

* `PickValue`
* `RecordQueryScoreForRankPlan` and `ScoreForRank`
* `RecordQueryInUnionPlan`
* `RecordQueryAggregateIndexPlan`
* `UserDefinedMacroFunction`
* `MultidimensionalIndexScanComparisons`
* `RangeConstraints`
* `PromoteValue.ArrayCoercionBiFunction`

The `PickValue` case is covered end-to-end by the new `CASE` queries in `skipped-field-number-proto.yamsql`.

Fixes #4873.
@robert-brunel
robert-brunel force-pushed the apple/robert-brunel/fix-proto-read-order branch from c1279c5 to 451d6d5 Compare November 10, 2026 18:59
@robert-brunel
robert-brunel marked this pull request as ready for review November 10, 2026 19:33

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug fix Change that fixes a bug

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Plan deserialization reads nested objects in a different order than they were serialized in

1 participant