Skip to content

fix(rulesets): restore null guard in duplicated-entry-in-enum (#2959)#2963

Open
slegarraga wants to merge 1 commit into
stoplightio:developfrom
slegarraga:fix/regression-2959-null-jsonpath
Open

fix(rulesets): restore null guard in duplicated-entry-in-enum (#2959)#2963
slegarraga wants to merge 1 commit into
stoplightio:developfrom
slegarraga:fix/regression-2959-null-jsonpath

Conversation

@slegarraga
Copy link
Copy Markdown
Contributor

Summary

Fixes #2959 — crash Cannot read properties of null (reading 'enum') when linting documents with null values under paths matched by the duplicated-entry-in-enum rule.

Regression from #2934 (my PR): the JSONPath filter was tightened to @.enum.constructor.name === 'Array' but dropped the @ && / null guard, so nimma evaluates @.enum on null nodes.

Fix

Restore @ != null in the given JSONPath while keeping the array filter from #2934.

Tests

Note

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

  • Tests added / updated
  • Docs added / updated (n/a)

Breaking change: No

Regression from stoplightio#2934: evaluating @.enum on null nodes (e.g. example values)
crashes Spectral (stoplightio#2959). Restores @ != null while keeping the array filter.
@slegarraga
Copy link
Copy Markdown
Contributor Author

See batch review note on #2961 — narrow hotfix for #2959 / #2934 regression. Happy to close if #2960 lands first.

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]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Missing null guard causes "Cannot read properties of null (reading 'enum')"

2 participants