stoplightio / spectral

A flexible JSON/YAML linter for creating automated style guides, with baked in support for OpenAPI v3.1, v3.0, and v2.0 as well as AsyncAPI v2.x.
https://stoplight.io/spectral
Apache License 2.0
2.35k stars 226 forks source link

Bug: Validation Error with @stoplight/spectral-rulesets 1.19.0 #2637

Closed tomo-kn closed 3 weeks ago

tomo-kn commented 4 weeks ago

Describe the bug After upgrading to @stoplight/spectral-rulesets version 1.19.0, we encountered a validation error that was not present in version 1.18.1.

The error message indicates a problem with spectral, specifically a TypeError: Cannot read properties of null (reading 'type').

[ERROR] There was a problem with spectral.
[ERROR] Cannot read properties of null (reading 'type')
[ERROR] Additional error details:
[ERROR] TypeError: Cannot read properties of null (reading 'type')
at $..[?(@.type === 'array')] (eval at query (/data/node_modules/nimma/dist/legacy/cjs/core/index.js:66:71), <anonymous>:10:31)
at eval (eval at query (/data/node_modules/nimma/dist/legacy/cjs/core/index.js:66:71), <anonymous>:182:41)
at _traverseBody (/data/node_modules/nimma/dist/legacy/cjs/runtime/traverse.js:13:5)
at _traverse (/data/node_modules/nimma/dist/legacy/cjs/runtime/traverse.js:41:7)
at _traverseBody (/data/node_modules/nimma/dist/legacy/cjs/runtime/traverse.js:17:5)
at _traverse (/data/node_modules/nimma/dist/legacy/cjs/runtime/traverse.js:41:7)
at _traverseBody (/data/node_modules/nimma/dist/legacy/cjs/runtime/traverse.js:17:5)
at _traverse (/data/node_modules/nimma/dist/legacy/cjs/runtime/traverse.js:41:7)
at _traverseBody (/data/node_modules/nimma/dist/legacy/cjs/runtime/traverse.js:17:5)
at _traverse **(/data/node_modules/nimma/dist/legacy/cjs/runtime/traverse.js:41:7)

To Reproduce

  1. Upgrade to @stoplight/spectral-rulesets version 1.19.0.
  2. Run the OpenAPI validation using ibm-openapi-validator or spectral.
  3. Observe the validation error

Expected behavior The OpenAPI validation should pass without any errors, as it did with @stoplight/spectral-rulesets version 1.18.1.

mi-wada commented 3 weeks ago

We encountered the same error. By adding the following configuration to .spectral.yaml to disable the array-items rule, the error was muted.

rules:
  array-items: off

It appears that array-items was added in @stoplight/spectral-rulesets 1.19.0 . There may be a bug in this rule 🤔

rainum commented 3 weeks ago

@tomo-kn, thanks for reporting this issue rapidly! It should be fixed by #2638. Sorry for the inconvenience that we may caused!

stoplight-bot commented 3 weeks ago

:tada: This issue has been resolved in version 1.19.1 :tada:

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

Your semantic-release bot :package::rocket: