Repository navigation
Description
PastaClaw flagged this while reviewing #6422, where it was deferred to a follow-up instead of being fixed in that pull request. This issue tracks the follow-up.
The definition and schema depth limits disagree in both directions (suggestion)
Impact: An author can be unable to import a registered schema with deeply nested contains clauses, and a Rust caller can export a nested object definition that the same API cannot read back.
Where: packages/rs-dpp/src/data_contract/document_type/definition/v0/nested.rs:21-28 at 9585611294a6:
platform/packages/rs-dpp/src/data_contract/document_type/definition/v0/nested.rs
Lines 21 to 28 in 9585611
| /// The deepest nesting a definition may hold, across everything of it that nests. | |
| /// | |
| /// A schema registration admits is at most 256 values deep (`max_depth`), and a property | |
| /// nested in an object sits two values deeper than the object (under its `properties`, then | |
| /// under its own name), so every nesting of properties a schema can register stays within the | |
| /// bound. A literal nests one value a level: a list of an `enum`, a `const` or an `examples` | |
| /// nested deeper than the bound has no definition. | |
| pub const MAX_DEFINITION_DEPTH: usize = 128; |
The two limits count different things. A top-level property followed by 127
propertiesmember edges stays inside V0's 128Nestedlevels, so export succeeds, but the exported schema has 257 containers and the current importer rejects it at 256. In the other direction, eachcontainsedge adds just one container and oneNestedlevel. Native registration'scompiled_patternsand the validation-schema builder follow those objects, so 129containsedges can fit under the registration cap while failing V0 import. Define a stack-safe schema round-trip boundary for both conversion directions, and account for registered shapes outside it before migration. Do not tighten historical registration to fit V0.
Origin
- Pull request: feat(dpp): typed definition of a document type, read from and written to its schema #6422
- Review thread: feat(dpp): typed definition of a document type, read from and written to its schema #6422 (comment)
- Filed by PastaClaw when it accepted the deferral, as nothing else tracked it.
Activity