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

Unexpected result while linting an empty document #1209

Closed
nulltoken opened this issue Jun 4, 2020 · 0 comments · Fixed by #1214
Closed

Unexpected result while linting an empty document #1209

nulltoken opened this issue Jun 4, 2020 · 0 comments · Fixed by #1214
Assignees
Labels
t/bug Something isn't working

Comments

@nulltoken
Copy link
Contributor

Describe the bug
Discovered while working on vscode-spectral.

To Reproduce

    test('x', async () => {
      const s = new Spectral({ resolver: httpAndFileResolver });

      for (const [format, lookup] of KNOWN_FORMATS) {
        // Each document type that Spectral can lint gets registered with detectors.
        s.registerFormat(format, document => lookup(document));
      }

      s.setRuleset(await readRuleset('spectral:oas'));

      const file = '/tmp/file.yaml';
      const doc = new Document('', Parsers.Yaml, file);

      const results = await s.run(doc, { ignoreUnknownFormat: true, resolve: { documentUri: file } })

      expect(results).toEqual([]);
    });
  });

Fail with

    - Array []
    + Array [
    +   Object {
    +     "code": "invalid-ref",
    +     "message": "'undefined' does not exist @ '/tmp/file.yaml'",
    +     "path": Array [
    +       "$ref",
    +     ],
    +     "range": Object {
    +       "end": Object {
    +         "character": 0,
    +         "line": 0,
    +       },
    +       "start": Object {
    +         "character": 0,
    +         "line": 0,
    +       },
    +     },
    +     "severity": 0,
    +     "source": "/tmp/file.yaml",
    +   },
    + ]

Expected behavior
Don't fail? 😉

@nulltoken nulltoken added the t/bug Something isn't working label Jun 4, 2020
@P0lip P0lip self-assigned this Jun 8, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
t/bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants