Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Invalid ruleset gives Error [object Object] #2186

Closed
philsturgeon opened this issue Jun 18, 2022 · 4 comments · Fixed by #2026
Closed

Invalid ruleset gives Error [object Object] #2186

philsturgeon opened this issue Jun 18, 2022 · 4 comments · Fixed by #2026
Labels

Comments

@philsturgeon
Copy link
Contributor

Describe the bug

An indentation error in a custom ruleset lead to a confusing error from spectral, leaving the user in an unclear state.

Spectral v6.4.1:

$ spectral lint example.yaml -r apisyouwonthate.yml
Error running Spectral!
Use --verbose flag to print the error stack.
Error #1: [object Object]

$ spectral lint example.yaml -r apisyouwonthate.yml --verbose
Error running Spectral!
Error #1: [object Object]

Spectral 6.2.0:

$ spectral lint example.yaml -r apisyouwonthate.yml
Error at #/: must NOT have additional properties

To Reproduce

  1. Given any OpenAPI document and this ruleset .spectral.yml:
rules:
  api-home:
    description: APIs MUST have a root path defined (`/`), to stop forcing all API consumers to visit documentation for basic interactions.
    severity: error
    given: $.paths
    then:
      field: /
      function: truthy

no-global-versioning:
  message: Server URL should not contain global versions
  given: $.servers[*].url
  then:
    function: pattern
    functionOptions:
      notMatch: /v[1-9]
  formats: oas3
  severity: warn
  1. Run this CLI command spectral lint https://raw.githubusercontent.com/stoplightio/Public-APIs/master/reference/plaid/openapi.yaml
  2. See error

Expected behavior
An error that explains my ruleset is invalid, ideally pointing to what I did wrong and where.

Error #1: Ruleset contained an unexpected key `no-global-versioning:`

or

Error #1: Ruleset should only contain `extends`, `formats`, or `rules` at the top level. 

Something like that.

Environment (remove any that are not applicable):

  • Library version: Spectral CLI v6.4.1
  • OS: macOS
@P0lip
Copy link
Contributor

P0lip commented Jun 18, 2022

This is fixed with #2026, but someone would need to review it 😬

@stoplight-bot
Copy link
Collaborator

🎉 This issue has been resolved in version @stoplight/spectral-cli-v6.5.0 🎉

The release is available on npm package (@latest dist-tag)

Your semantic-release bot 📦🚀

@stoplight-bot
Copy link
Collaborator

🎉 This issue has been resolved in version @stoplight/spectral-core-v1.13.0 🎉

The release is available on npm package (@latest dist-tag)

Your semantic-release bot 📦🚀

@stoplight-bot
Copy link
Collaborator

🎉 This issue has been resolved in version @stoplight/spectral-functions-v1.7.0 🎉

The release is available on npm package (@latest dist-tag)

Your semantic-release bot 📦🚀

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 a pull request may close this issue.

3 participants