Skip to content

The definition and schema depth limits disagree in both directions #6426

Backlog

Description

@thepastaclaw

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:

/// 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 properties member edges stays inside V0's 128 Nested levels, so export succeeds, but the exported schema has 257 containers and the current importer rejects it at 256. In the other direction, each contains edge adds just one container and one Nested level. Native registration's compiled_patterns and the validation-schema builder follow those objects, so 129 contains edges 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

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions