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

Percent-encoding JSON Pointers in #2511 introduced a breaking change in spectral-core and spectral-cli #2515

Open
dlkj opened this issue Jul 25, 2023 · 3 comments
Labels

Comments

@dlkj
Copy link

dlkj commented Jul 25, 2023

Describe the bug

#2511 has introduced a breaking change for rule override JSON Pointers. Different minor versions of spectral-core require different rule override files.

To Reproduce

  1. create an override with a character that could be percent encoded, for example:
extends: ruleset.yaml
overrides:
  - files:
      - openapi.yaml#/resource:custom-method/post/requestBody
    rules:
      my-rule: off
  1. override works with spectral-core 1.18.2
  2. override fails with spectral-core 1.18.3
  3. changing the override to the following fixes 1.18.3 but breaks 1.18.2. Note the changing of ":" to "%3A"
extends: ruleset.yaml
overrides:
  - files:
      - openapi.yaml#/resource%3Acustom-method/post/requestBody
    rules:
      my-rule: off

Expected behavior

This should have been released as a breaking change, requiring a bump of the spectral-cli version number. Currently we have 6.6.0 of stoplight/spectral-cli showing both of theses behaviours depending on when it was installed from NPM (and which version of spectral-core was resolved.

Environment (remove any that are not applicable):

  • spectral-cli 6.6.0
  • Node.JS 18.16.0
  • OS: Windows 10, Ubuntu 22.04
@anikitin
Copy link

anikitin commented Aug 8, 2023

Faced similar issue with curly brackets in path overrides. Replaced them in my rules with %7B and %7D, it fixed the issue.
At the same time Spectral VS Code plugin still operates with old version of spectral-core and doesn't recognize this escaped syntax properly. So as a workaround need to duplicate override rules in old and new format to support both CLI and VS Code.

@mnaumanali94
Copy link
Contributor

Need to update vs code extension here: stoplightio/vscode-spectral#216

Would that solve the issue for y'all?

@anikitin
Copy link

anikitin commented May 3, 2024

@mnaumanali94

Need to update vs code extension here: stoplightio/vscode-spectral#216

Would that solve the issue for y'all?

I think at least it would help make my rule definition cleaner. This is what we experience often: VS Code extension is not updated promptly with the latest version of Spectral Core, so the way how our CI works with its up-to-date spectral-cli version does not necessarily replicate what our developers see in their VS Code interface. So, I think that more regular updates of VS Code extension after core updates would help to avoid such kinds of issues.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants