Repository navigation
Add a maximum depth of 128 levels - #83
Merged
Merged
Conversation
Specs for objects in chains, in collections and in collections of collections. An object at level 128 is validated. An object at level 129 is not validated and fails the validation with an error at its path. These specs fail until the limit is added. Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
The walk calls itself once for each level, so a graph of about 1,500 objects, or a property that builds a new object on each read, overflowed the stack. An object at a path of more than 128 segments is now not validated, and the validation fails with one error at its path. Tests that used a deeper graph now stay below the limit. Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
This was referenced Oct 2, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Motivation
The validator calls itself once for each level of the object graph, and .NET cannot catch a StackOverflowException. A chain of about 1,500 objects, or a property that builds a new object on each read (
Vector Zero => new Vector()) on a type without anEqualsoverride, ends the process. This was the open "maximum depth" item for the 3.0 series. The limit is 128, which is twice the default depth of System.Text.Json and Newtonsoft. A JSON document within the limit of 64 stays within about 63 levels here.Past the limit the validation fails. It does not throw and it does not stop silently, because a graph that nobody validated must not pass.
Summary
Test plan
-p:IncludeNetFramework=true.