Repository navigation
fix: check max depth for every depth a fragment is spread at - #780
Merged
pavelnikolov merged 1 commit intoOct 7, 2026
Merged
Conversation
Contributor
There was a problem hiding this comment.
Copilot review overview
🟢 Approval recommended
The depth-aware traversal is correct, bounded, and adequately covered by regression tests.
Review effort: Balanced
Findings: None
What changed in this PR
Fixes max-depth validation for fragments reused at different nesting depths.
Changes:
- Tracks visited fragments by definition and depth.
- Adds valid regression tests for direct and chained fragment spreads.
| File | Description |
|---|---|
internal/validation/validation.go |
Corrects fragment depth traversal and cycle handling. |
internal/validation/validate_max_depth_test.go |
Adds targeted regression coverage. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
pavelnikolov
enabled auto-merge
October 7, 2026 21:17
pavelnikolov
approved these changes
Oct 7, 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.
validateMaxDepthguards against fragment cycles with a singlevisitedset for the whole operation. Once a fragment has been checked, every later spread of it is skipped, including spreads at a greater depth, where its fields are deeper. A query can exceedMaxDepthby spreading a fragment shallowly before spreading it deeply, or reach any depth with a chain of fragments that are each spread once near the top first.This keys
visitedby fragment and depth instead. A spread at a depth that has already been checked is still skipped, so cycles still terminate, and depth never exceedsmaxDepth+1because fields beyond the limit are not descended into, so each fragment is walked at mostmaxDepth+1times.The existing
spreadAtDifferentDepthscase covered this scenario but passed only because its query also failed type validation (PossibleFragmentSpreadsRule,FieldsOnCorrectTypeRule); noMaxDepthExceedederror was produced. It now uses a valid query and assertsMaxDepthExceeded, andfragmentChainSpreadShallowFirstcovers the chain. Both fail onmain.