Skip to content

fix(rulesets): duplicated-entry-in-enum - support null values#2960

Open
DougEdey-Slice wants to merge 1 commit into
stoplightio:developfrom
DougEdey-Slice:fix_enum_dupes
Open

fix(rulesets): duplicated-entry-in-enum - support null values#2960
DougEdey-Slice wants to merge 1 commit into
stoplightio:developfrom
DougEdey-Slice:fix_enum_dupes

Conversation

@DougEdey-Slice
Copy link
Copy Markdown

@DougEdey-Slice DougEdey-Slice commented May 21, 2026

Fixes #2959.

This handles null enum values, which is supported/required by OAS3.1 for nullable enums

This updates the tests & the ruleset to support nulls, which OAS3.0 does support: https://swagger.io/docs/specification/v3_0/data-models/enums/#nullable-enums

First time contributor so let me know if I need anything else :)

Checklist

  • Tests added / updated
  • Docs added / updated

Does this PR introduce a breaking change?

  • No

@DougEdey-Slice DougEdey-Slice requested a review from a team as a code owner May 21, 2026 14:01
@slegarraga
Copy link
Copy Markdown
Contributor

Nice follow-up to the enum edge cases — null in enum arrays is easy to miss. From #2934 land: worth confirming resolved: false behavior on $ref-wrapped enums matches your test cases. Thanks for pushing this.

Copy link
Copy Markdown
Contributor

@slegarraga slegarraga left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM — null enum handling matches OAS 3.0 nullable enums and 3.1 semantics from #2959.

  • Test matrix covers null in enum arrays without false positives on valid enums.
  • validators.ts tweak is minimal and scoped to the duplicated-entry rule path.

No concerns from my side; thanks for the fix.

Copy link
Copy Markdown
Contributor

@slegarraga slegarraga left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM — null enum handling matches #2959; tests cover nullable enums without false positives. Thanks for the fix.

@slegarraga
Copy link
Copy Markdown
Contributor

@DougEdey-Slice Thanks — this addresses the regression from #2934 (my merge). Suggest adding a test case for issue #2959 reproducer (components.examples.*.value with foo: null) so we don’t regress the JSONPath guard again. Approved from my side.

@slegarraga
Copy link
Copy Markdown
Contributor

Opened #2963 with the #2959 reproducer test + same guard — happy to close #2963 if you prefer landing this PR instead.

@slegarraga
Copy link
Copy Markdown
Contributor

@tomek-tursa-sb Maintainer review when possible — 2 contributor approvals, fixes #2959 (production crash). Alternative: #2963 has the same guard + explicit reproducer test from the issue. Either PR unblocks users on spectral-cli 6.16.x.

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')"

3 participants