fix: do not run nested visitors with a stale parent on shared $refs - #3038
Open
vadyvas wants to merge 1 commit into
Open
fix: do not run nested visitors with a stale parent on shared $refs#3038vadyvas wants to merge 1 commit into
vadyvas wants to merge 1 commit into
Conversation
🦋 Changeset detectedLatest commit: 5467388 The changes in this PR will be included in the next version bump. This PR includes changesets to release 4 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
Contributor
Author
|
@cursor review |
Contributor
Coverage Report
File Coverage
|
||||||||||||||||||||||||||||||||||||||
Contributor
Performance Benchmark (Lower is Faster)
|
There was a problem hiding this comment.
✅ Bugbot reviewed your changes and found no new issues!
Comment @cursor review or bugbot run to trigger another review on this PR
Reviewed by Cursor Bugbot for commit 5467388. Configure here.
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.
What/Why/How?
operation-parameters-uniquereported a duplicate parameter that is not there. It happens when the same path item is reused through$ref, for example from two callbacks, and the reported location points at an operation that has noparametersat all.The reason is in the walker. Two
$refs to the same path item resolve to one object, so the walker enters it twice. On the second entry it does not call the rule'senterhooks again, because it already called them for that node — but it still calls the rule's nestedParametervisitor. So the visitor runs with the state and the parent location left over from the first entry, and reports a parameter it had already counted.Added a guard: a nested visitor now runs only if the node its parent hook sits on is the node the walker is really inside. On the second entry the
Parametervisitor stays quiet, and the rule reports only what it actually saw.operation-parameters-uniqueis not the only rule with this shape —spec-querystring-parametershad the same problem.Reference
Closes #2829
Testing
Screenshots (optional)
x-signatureis declared once, in one list:Before:
After:
Check yourself
Security
Note
Medium Risk
Changes core document-walking logic used by every lint rule; behavior is narrowly scoped with new tests, but regressions in visitor ordering or ref handling are possible.
Overview
Fixes false duplicate-parameter errors when the same path item is referenced from multiple
$refs (e.g. two callbacks pointing at#/components/pathItems/notify). Rules likeoperation-parameters-uniquecould report duplicates on an operation that has noparameters, because the walker re-entered the shared resolved object without re-running parententerhooks but still fired nestedParametervisitors with leftover parent state.The OpenAPI document walker now tracks the resolved node currently being walked per node type (
walkingNodeByType). A nested visitor is only activated when the parent hook’s stored node matches that active node, so the second entry through a shared$refdoes not run nested visitors with a stale parent.Unit tests cover shared path items in callbacks and nested rules beside
$refsiblings; an e2e fixture confirms lint passes for the callback reuse scenario.Reviewed by Cursor Bugbot for commit 5467388. Bugbot is set up for automated code reviews on this repo. Configure here.