question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Error disabling an extended ruleset in an extended ruleset

See original GitHub issue

Describe the bug When I structure my rules like so:

index.json

{
  "extends": [
    "rules-one.json",
    "rules-two.json",
  ]
}

rules-one.json

{
  "extends": ["spectral:oas", "off"],
  "rules": {
    "path-params": true
  }
}

…and then load them like so:

const spectral = new Spectral();
spectral.registerFormat("oas3", isOpenApiv3);
await spectral.loadRuleset(path.resolve("***/index.json"));

I get the following error:

    Error: Provided ruleset is not an object
        at Object.assertValidRuleset (/***/node_modules/@stoplight/spectral/dist/rulesets/validation.js:23:15)
        at processRuleset (/***/node_modules/@stoplight/spectral/dist/rulesets/reader.js:62:38)
        at process._tickCallback (internal/process/next_tick.js:68:7)

This does not occur if:

  • I don’t disable the spectral:oas rules
  • I extend and disable them in index.json instead of rules-one.json

I also tried to extend/disable the spectral rules in index.json and then enable specific ones in rules-one.json but that didn’t work (they don’t get enabled).

I printed the ruleset that fails to validate and it’s an IIFE that starts with: (function (root, factory) { if (typeof define === \"function\" && define.amd) {

To Reproduce

  1. Set up and load rules as described above
  2. Observe error

Expected behavior The rules load successfully and allow me to disable an extended ruleset, in an extended ruleset, and then selectively enable them.

Environment (remove any that are not applicable):

  • Library version: 5.5.0
  • OS: macOS 10.15.6

Additional context I organised my rules to be aligned with the OAS schema objects (e.g. operation-object.json) to keep things manageable. I want to enable specific spectral:oas rules alongside related, custom ones.

Workaround is to extend/disable in index.json and then enable specific rules there too.

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:7 (7 by maintainers)

github_iconTop GitHub Comments

1reaction
adanilevcommented, Sep 29, 2020

@P0lip, yep, that’s the issue I’m referring to.

0reactions
mkistlercommented, Dec 24, 2020

Well … curiously … things work a bit differently if you don’t disable all the rules with extends: [[spectral:oas, off]] and instead disable each one individually. With that approach, you can extend the ruleset without disabled (but “recommended”) rules becoming enabled again.

So it does seem like there is an inconsistency here. If extends: [[spectral:oas, off]] could be made to work like disabling all the rules individually, I think that would resolve the inconsistency in a way that would match most people’s expectations.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Suggestion: Allow disabling rules in extended Profiles
I have seen in this post (Extended Quality profile has no option to deactivate rules - #6 by ganncamp) that current state of...
Read more >
Some rules are disabled and can't be enabled - Outlook
If you try to enable the rules that are disabled, you receive the following error message: One or more rules couldn't be uploaded...
Read more >
How to enable or disable Error checking rules in Microsoft Excel
Error -checking rules help verify formulas in Excel. Learn how to enable, disable, or manage Error checking rules in Microsoft Excel.
Read more >
Configuring Rules - CodeNarc
Specifying codenarc-disable disables all CodeNarc rules, or it can optionally be followed by one or more rule names to disable only the named...
Read more >
Understanding WAF managed rules (Web Application Firewall)
It is, however, important that customers tune their managed rules configuration. Cloudflare is working on a better long term solution.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found