fix(rulesets): restore null guard in duplicated-entry-in-enum (#2959)#2963
Open
slegarraga wants to merge 1 commit into
Open
fix(rulesets): restore null guard in duplicated-entry-in-enum (#2959)#2963slegarraga wants to merge 1 commit into
slegarraga wants to merge 1 commit into
Conversation
Regression from stoplightio#2934: evaluating @.enum on null nodes (e.g. example values) crashes Spectral (stoplightio#2959). Restores @ != null while keeping the array filter.
Contributor
Author
2 tasks
carlhoerberg
pushed a commit
to cloudamqp/lavinmq
that referenced
this pull request
May 25, 2026
## Summary - Pin `@stoplight/spectral-rulesets` to `1.22.2` in the `lint-openapi` target. - `1.22.3` introduced a regression in the `duplicated-entry-in-enum` rule that crashes Spectral with `Cannot read properties of null (reading 'enum')`. See [stoplightio/spectral#2959](stoplightio/spectral#2959). - Fix is in flight upstream ([#2960](stoplightio/spectral#2960) / [#2963](stoplightio/spectral#2963)) --------- Co-authored-by: Patrik Ragnarsson <[email protected]>
noahg1
approved these changes
May 27, 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.
Summary
Fixes #2959 — crash
Cannot read properties of null (reading 'enum')when linting documents withnullvalues under paths matched by theduplicated-entry-in-enumrule.Regression from #2934 (my PR): the JSONPath filter was tightened to
@.enum.constructor.name === 'Array'but dropped the@ &&/ null guard, so nimma evaluates@.enumonnullnodes.Fix
Restore
@ != nullin thegivenJSONPath while keeping the array filter from #2934.Tests
components.examples.*.value.foo: null)yarn test.jest --testPathPattern=duplicated-entry-in-enum→ 9/9 passNote
Overlaps #2960 (nullable enum + same guard). Happy to close this in favor of #2960 if maintainers prefer a single PR — this one is narrowly scoped to the production crash reproducer and follow-up to #2934.
Checklist
Breaking change: No