Skip to content

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

Merged
Patrycja Dziemianko (Patrycja-dz) merged 2 commits into
stoplightio:developfrom
DougEdey-Slice:fix_enum_dupes
Jul 30, 2026
Merged

Patrycja Dziemianko (Patrycja-dz) merged 2 commits into
stoplightio:developfrom
DougEdey-Slice:fix_enum_dupes

Conversation

@DougEdey-Slice

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

Copy link
Copy Markdown
Contributor

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

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

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

This comment has been minimized.

Carl Hörberg (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]>

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Reviewed this against #2959 and my own #2963, since they overlap.

The 3.1 coverage here is the right call: null is a valid enum member in OAS 3.1 (enum: [1, 2, 3, null]), and flagging duplicated nulls ([null, …, null] → items #0 and #6) is a real gap the original rule missed. Nice.

One coordination note: this and #2963 fix different facets of #2959 and will conflict on oas/index.ts and duplicated-entry-in-enum.test.ts. #2963 adds @ != null to the rule's given selector to stop a TypeError when the selector hits a null node (e.g. foo: null inside an example value, where reading @.enum throws). That null-node crash isn't exercised by the cases here (these are all schema enums), so I think both changes are needed: the selector guard to avoid the crash, plus your 3.1 null-entry semantics. Happy to rebase #2963 on top of this so it's a single clean change if that's easier to merge.

@DougEdey-Slice

Copy link
Copy Markdown
Contributor Author

tomek-tursa-sb pareshb3089 Could we get a review on this please?

@Patrycja-dz
Patrycja Dziemianko (Patrycja-dz) merged commit eabe7f5 into stoplightio:develop Jul 30, 2026
8 checks passed
卜部昌平 (shyouhei) added a commit to sacloud/sacloud-sdk-go that referenced this pull request Aug 3, 2026
I think we need to wait for:
stoplightio/spectral#2960

Signed-off-by: 卜部 昌平 <[email protected]>
Stoplighticus Roboticus (stoplight-bot) pushed a commit that referenced this pull request Aug 3, 2026
## [1.22.7](https://github.com/stoplightio/spectral/compare/@stoplight/spectral-rulesets-1.22.6...@stoplight/spectral-rulesets-1.22.7) (2026-08-03)

### Bug Fixes

* add GOPATH bin to PATH for ghr command ([#3008](#3008)) ([71cdeb1](71cdeb1))
* docker image release ([#3004](#3004)) ([e929dea](e929dea))
* **repo:** docker image ci cd ([#3009](#3009)) ([3a5c40c](3a5c40c))
* **repo:** docker image release ([#3000](#3000)) ([6af0317](6af0317))
* **repo:** docker image release ([#3001](#3001)) ([0234765](0234765))
* **repo:** docker image release ([#3002](#3002)) ([fa50e6a](fa50e6a))
* **repo:** docker image release ([#3003](#3003)) ([0f5d42a](0f5d42a))
* **repo:** docker image release ([#3005](#3005)) ([fd21616](fd21616))
* **repo:** docker image release ([#3006](#3006)) ([c62dbb7](c62dbb7))
* **repo:** fix ruleset test ([#3016](#3016)) ([0d46443](0d46443))
* **rulesets:** duplicated-entry-in-enum - support null values in enums when checking for duplicates ([#2960](#2960)) ([eabe7f5](eabe7f5))
* split binary build into separate steps ([#3007](#3007)) ([30aa1e0](30aa1e0))
* trigger release action ([#3026](#3026)) ([f85f1a6](f85f1a6))
* updated yarn lock ([#2992](#2992)) ([076f0d2](076f0d2))
* updates cli readme ([#2998](#2998)) ([dbcb26e](dbcb26e))

### Features

* **repo:** add scarf to docker image ([#3010](#3010)) ([cd88ea8](cd88ea8))
@stoplight-bot

Copy link
Copy Markdown
Collaborator

🎉 This PR is included in version 1.22.7 🎉

The release is available on @stoplight/spectral-rulesets-1.22.7

Your semantic-release bot 📦🚀

Herbert Damker (hdamker) added a commit to camaraproject/tooling that referenced this pull request Aug 5, 2026
Upstream shipped the null-guard fix (stoplightio/spectral#2960) in
1.22.7, so the 1.22.2 pin from #329 is no longer needed. Lockfile now
resolves and hoists a single 1.22.7 copy.
Stoplighticus Roboticus (stoplight-bot) pushed a commit that referenced this pull request Oct 1, 2026
# [1.9.0](https://github.com/stoplightio/spectral/compare/@stoplight/spectral-formats-1.8.5...@stoplight/spectral-formats-1.9.0) (2026-10-01)

### Bug Fixes

* add GOPATH bin to PATH for ghr command ([#3008](#3008)) ([71cdeb1](71cdeb1))
* **core:** make JSON Schemas at `packages/core/src/ruleset/meta` valid ([#2788](#2788)) ([e5143e7](e5143e7))
* docker image release ([#3004](#3004)) ([e929dea](e929dea))
* format md file ([#3027](#3027)) ([39d522a](39d522a))
* **formatters:** include all results in markdown output ([#3039](#3039)) ([667818e](667818e))
* **formatters:** include ruleset-based documentationUrl in github format ([#3063](#3063)) ([f30aa41](f30aa41))
* **repo:** docker image ci cd ([#3009](#3009)) ([3a5c40c](3a5c40c))
* **repo:** docker image release ([#3000](#3000)) ([6af0317](6af0317))
* **repo:** docker image release ([#3001](#3001)) ([0234765](0234765))
* **repo:** docker image release ([#3002](#3002)) ([fa50e6a](fa50e6a))
* **repo:** docker image release ([#3003](#3003)) ([0f5d42a](0f5d42a))
* **repo:** docker image release ([#3005](#3005)) ([fd21616](fd21616))
* **repo:** docker image release ([#3006](#3006)) ([c62dbb7](c62dbb7))
* **repo:** fix ruleset test ([#3016](#3016)) ([0d46443](0d46443))
* **repo:** prevent script injection in release-docker workflow ([#3024](#3024)) ([ee5455d](ee5455d)), closes [9-#12](https://github.com/9-/issues/12)
* **repo:** report download failures in install.sh ([#3041](#3041)) ([01789ae](01789ae))
* **rulesets:** clarify operationId URL validation message ([#3035](#3035)) ([4fb7331](4fb7331))
* **rulesets:** duplicated-entry-in-enum - support null values in enums when checking for duplicates ([#2960](#2960)) ([eabe7f5](eabe7f5))
* **rulesets:** restore null guard in duplicated-entry-in-enum JSONPath ([#2963](#2963)) ([c6e46d0](c6e46d0)), closes [#2959](#2959)
* split binary build into separate steps ([#3007](#3007)) ([30aa1e0](30aa1e0))
* **test-harness:** suppress Node.js deprecation warnings in Windows harness ([#3075](#3075)) ([661f41c](661f41c))
* **test-harness:** use RUNNER_TEMP instead of /tmp on Windows runner ([#3074](#3074)) ([4ec4148](4ec4148))
* trigger release action ([#3026](#3026)) ([f85f1a6](f85f1a6))
* updated yarn lock ([#2992](#2992)) ([076f0d2](076f0d2))
* updates cli readme ([#2998](#2998)) ([dbcb26e](dbcb26e))

### Features

* **asyncapi:** add 3.1 support and future minor fallback ([#3019](#3019)) ([23e2afa](23e2afa))
* **repo:** add scarf to docker image ([#3010](#3010)) ([cd88ea8](cd88ea8))
Stoplighticus Roboticus (stoplight-bot) pushed a commit that referenced this pull request Oct 1, 2026
## [1.5.2](https://github.com/stoplightio/spectral/compare/@stoplight/spectral-formatters-1.5.1...@stoplight/spectral-formatters-1.5.2) (2026-10-01)

### Bug Fixes

* add GOPATH bin to PATH for ghr command ([#3008](#3008)) ([71cdeb1](71cdeb1))
* added scarf ([#2980](#2980)) ([9db5703](9db5703))
* added scarf to formats ([#2982](#2982)) ([d9f8066](d9f8066))
* added scarf to functions ([#2984](#2984)) ([b16373e](b16373e))
* added scarf to rulesets ([#2981](#2981)) ([31dc115](31dc115))
* **core:** make JSON Schemas at `packages/core/src/ruleset/meta` valid ([#2788](#2788)) ([e5143e7](e5143e7))
* **deps:** post lodash update changes for semantic release ([#2942](#2942)) ([bf530dd](bf530dd))
* docker image release ([#3004](#3004)) ([e929dea](e929dea))
* fixed version of core package ([#2989](#2989)) ([5f0e6c6](5f0e6c6))
* fixed version of formats package ([#2987](#2987)) ([b6952ec](b6952ec))
* fixed version of functions package ([#2986](#2986)) ([30a8c66](30a8c66))
* fixed version of rulesets package ([#2988](#2988)) ([cd4f0f6](cd4f0f6))
* format md file ([#3027](#3027)) ([39d522a](39d522a))
* **formatters:** include all results in markdown output ([#3039](#3039)) ([667818e](667818e))
* **formatters:** include ruleset-based documentationUrl in github format ([#3063](#3063)) ([f30aa41](f30aa41))
* remove `abort-controller` ([#2948](#2948)) ([682295a](682295a))
* **repo:** docker image ci cd ([#3009](#3009)) ([3a5c40c](3a5c40c))
* **repo:** docker image release ([#3000](#3000)) ([6af0317](6af0317))
* **repo:** docker image release ([#3001](#3001)) ([0234765](0234765))
* **repo:** docker image release ([#3002](#3002)) ([fa50e6a](fa50e6a))
* **repo:** docker image release ([#3003](#3003)) ([0f5d42a](0f5d42a))
* **repo:** docker image release ([#3005](#3005)) ([fd21616](fd21616))
* **repo:** docker image release ([#3006](#3006)) ([c62dbb7](c62dbb7))
* **repo:** fix ruleset test ([#3016](#3016)) ([0d46443](0d46443))
* **repo:** prevent script injection in release-docker workflow ([#3024](#3024)) ([ee5455d](ee5455d)), closes [9-#12](https://github.com/9-/issues/12)
* **repo:** report download failures in install.sh ([#3041](#3041)) ([01789ae](01789ae))
* **ruleset-migrator:** handle non function objects returned by requireResolve ([#2957](#2957)) ([60c6c56](60c6c56))
* **rulesets:** clarify operationId URL validation message ([#3035](#3035)) ([4fb7331](4fb7331))
* **rulesets:** duplicated-entry-in-enum - support null values in enums when checking for duplicates ([#2960](#2960)) ([eabe7f5](eabe7f5))
* **rulesets:** exclude non-schema enum properties from duplicated-entry-in-enum rule ([#2934](#2934)) ([a7822fa](a7822fa)), closes [#2199](#2199)
* **rulesets:** fix handling relative references in externalValue ([#2944](#2944)) ([6666ccc](6666ccc)), closes [#2819](#2819)
* **rulesets:** restore null guard in duplicated-entry-in-enum JSONPath ([#2963](#2963)) ([c6e46d0](c6e46d0)), closes [#2959](#2959)
* split binary build into separate steps ([#3007](#3007)) ([30aa1e0](30aa1e0))
* **test-harness:** suppress Node.js deprecation warnings in Windows harness ([#3075](#3075)) ([661f41c](661f41c))
* **test-harness:** use RUNNER_TEMP instead of /tmp on Windows runner ([#3074](#3074)) ([4ec4148](4ec4148))
* trigger release action ([#3026](#3026)) ([f85f1a6](f85f1a6))
* unpinned versions of spectral-core ([#2990](#2990)) ([966b665](966b665))
* updated yarn lock ([#2991](#2991)) ([c287898](c287898))
* updated yarn lock ([#2992](#2992)) ([076f0d2](076f0d2))
* updates cli readme ([#2998](#2998)) ([dbcb26e](dbcb26e))

### Features

* **asyncapi:** add 3.1 support and future minor fallback ([#3019](#3019)) ([23e2afa](23e2afa))
* **core:** add error line number for yaml and json ruleset validation ([#2945](#2945)) ([04c1db3](04c1db3))
* **repo:** add scarf to docker image ([#3010](#3010)) ([cd88ea8](cd88ea8))
Stoplighticus Roboticus (stoplight-bot) pushed a commit that referenced this pull request Oct 1, 2026
# [1.11.0](https://github.com/stoplightio/spectral/compare/@stoplight/spectral-functions-1.10.5...@stoplight/spectral-functions-1.11.0) (2026-10-01)

### Bug Fixes

* add GOPATH bin to PATH for ghr command ([#3008](#3008)) ([71cdeb1](71cdeb1))
* **core:** make JSON Schemas at `packages/core/src/ruleset/meta` valid ([#2788](#2788)) ([e5143e7](e5143e7))
* docker image release ([#3004](#3004)) ([e929dea](e929dea))
* format md file ([#3027](#3027)) ([39d522a](39d522a))
* **formatters:** include all results in markdown output ([#3039](#3039)) ([667818e](667818e))
* **formatters:** include ruleset-based documentationUrl in github format ([#3063](#3063)) ([f30aa41](f30aa41))
* **repo:** docker image ci cd ([#3009](#3009)) ([3a5c40c](3a5c40c))
* **repo:** docker image release ([#3000](#3000)) ([6af0317](6af0317))
* **repo:** docker image release ([#3001](#3001)) ([0234765](0234765))
* **repo:** docker image release ([#3002](#3002)) ([fa50e6a](fa50e6a))
* **repo:** docker image release ([#3003](#3003)) ([0f5d42a](0f5d42a))
* **repo:** docker image release ([#3005](#3005)) ([fd21616](fd21616))
* **repo:** docker image release ([#3006](#3006)) ([c62dbb7](c62dbb7))
* **repo:** fix ruleset test ([#3016](#3016)) ([0d46443](0d46443))
* **repo:** prevent script injection in release-docker workflow ([#3024](#3024)) ([ee5455d](ee5455d)), closes [9-#12](https://github.com/9-/issues/12)
* **repo:** report download failures in install.sh ([#3041](#3041)) ([01789ae](01789ae))
* **rulesets:** clarify operationId URL validation message ([#3035](#3035)) ([4fb7331](4fb7331))
* **rulesets:** duplicated-entry-in-enum - support null values in enums when checking for duplicates ([#2960](#2960)) ([eabe7f5](eabe7f5))
* **rulesets:** restore null guard in duplicated-entry-in-enum JSONPath ([#2963](#2963)) ([c6e46d0](c6e46d0)), closes [#2959](#2959)
* split binary build into separate steps ([#3007](#3007)) ([30aa1e0](30aa1e0))
* **test-harness:** suppress Node.js deprecation warnings in Windows harness ([#3075](#3075)) ([661f41c](661f41c))
* **test-harness:** use RUNNER_TEMP instead of /tmp on Windows runner ([#3074](#3074)) ([4ec4148](4ec4148))
* trigger release action ([#3026](#3026)) ([f85f1a6](f85f1a6))
* updated yarn lock ([#2992](#2992)) ([076f0d2](076f0d2))
* updates cli readme ([#2998](#2998)) ([dbcb26e](dbcb26e))

### Features

* **asyncapi:** add 3.1 support and future minor fallback ([#3019](#3019)) ([23e2afa](23e2afa))
* **repo:** add scarf to docker image ([#3010](#3010)) ([cd88ea8](cd88ea8))
* **repo:** minor release trigger ([#3079](#3079)) ([eabafec](eabafec))
Stoplighticus Roboticus (stoplight-bot) pushed a commit that referenced this pull request Oct 1, 2026
# [1.8.0](https://github.com/stoplightio/spectral/compare/@stoplight/spectral-ruleset-bundler-1.7.0...@stoplight/spectral-ruleset-bundler-1.8.0) (2026-10-01)

### Bug Fixes

* add GOPATH bin to PATH for ghr command ([#3008](#3008)) ([71cdeb1](71cdeb1))
* added scarf ([#2980](#2980)) ([9db5703](9db5703))
* added scarf to formats ([#2982](#2982)) ([d9f8066](d9f8066))
* added scarf to functions ([#2984](#2984)) ([b16373e](b16373e))
* added scarf to rulesets ([#2981](#2981)) ([31dc115](31dc115))
* **core:** make JSON Schemas at `packages/core/src/ruleset/meta` valid ([#2788](#2788)) ([e5143e7](e5143e7))
* **deps:** post lodash update changes for semantic release ([#2942](#2942)) ([bf530dd](bf530dd))
* docker image release ([#3004](#3004)) ([e929dea](e929dea))
* fixed version of core package ([#2989](#2989)) ([5f0e6c6](5f0e6c6))
* fixed version of formats package ([#2987](#2987)) ([b6952ec](b6952ec))
* fixed version of functions package ([#2986](#2986)) ([30a8c66](30a8c66))
* fixed version of rulesets package ([#2988](#2988)) ([cd4f0f6](cd4f0f6))
* format md file ([#3027](#3027)) ([39d522a](39d522a))
* **formatters:** include all results in markdown output ([#3039](#3039)) ([667818e](667818e))
* **formatters:** include ruleset-based documentationUrl in github format ([#3063](#3063)) ([f30aa41](f30aa41))
* remove `abort-controller` ([#2948](#2948)) ([682295a](682295a))
* **repo:** docker image ci cd ([#3009](#3009)) ([3a5c40c](3a5c40c))
* **repo:** docker image release ([#3000](#3000)) ([6af0317](6af0317))
* **repo:** docker image release ([#3001](#3001)) ([0234765](0234765))
* **repo:** docker image release ([#3002](#3002)) ([fa50e6a](fa50e6a))
* **repo:** docker image release ([#3003](#3003)) ([0f5d42a](0f5d42a))
* **repo:** docker image release ([#3005](#3005)) ([fd21616](fd21616))
* **repo:** docker image release ([#3006](#3006)) ([c62dbb7](c62dbb7))
* **repo:** fix ruleset test ([#3016](#3016)) ([0d46443](0d46443))
* **repo:** prevent script injection in release-docker workflow ([#3024](#3024)) ([ee5455d](ee5455d)), closes [9-#12](https://github.com/9-/issues/12)
* **repo:** report download failures in install.sh ([#3041](#3041)) ([01789ae](01789ae))
* **ruleset-migrator:** handle non function objects returned by requireResolve ([#2957](#2957)) ([60c6c56](60c6c56))
* **rulesets:** clarify operationId URL validation message ([#3035](#3035)) ([4fb7331](4fb7331))
* **rulesets:** duplicated-entry-in-enum - support null values in enums when checking for duplicates ([#2960](#2960)) ([eabe7f5](eabe7f5))
* **rulesets:** exclude non-schema enum properties from duplicated-entry-in-enum rule ([#2934](#2934)) ([a7822fa](a7822fa)), closes [#2199](#2199)
* **rulesets:** fix handling relative references in externalValue ([#2944](#2944)) ([6666ccc](6666ccc)), closes [#2819](#2819)
* **rulesets:** restore null guard in duplicated-entry-in-enum JSONPath ([#2963](#2963)) ([c6e46d0](c6e46d0)), closes [#2959](#2959)
* split binary build into separate steps ([#3007](#3007)) ([30aa1e0](30aa1e0))
* **test-harness:** suppress Node.js deprecation warnings in Windows harness ([#3075](#3075)) ([661f41c](661f41c))
* **test-harness:** use RUNNER_TEMP instead of /tmp on Windows runner ([#3074](#3074)) ([4ec4148](4ec4148))
* trigger release action ([#3026](#3026)) ([f85f1a6](f85f1a6))
* unpinned versions of spectral-core ([#2990](#2990)) ([966b665](966b665))
* updated yarn lock ([#2991](#2991)) ([c287898](c287898))
* updated yarn lock ([#2992](#2992)) ([076f0d2](076f0d2))
* updates cli readme ([#2998](#2998)) ([dbcb26e](dbcb26e))

### Features

* **asyncapi:** add 3.1 support and future minor fallback ([#3019](#3019)) ([23e2afa](23e2afa))
* **core:** add error line number for yaml and json ruleset validation ([#2945](#2945)) ([04c1db3](04c1db3))
* **repo:** add scarf to docker image ([#3010](#3010)) ([cd88ea8](cd88ea8))
* **repo:** minor release trigger ([#3079](#3079)) ([eabafec](eabafec))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

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

6 participants