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 token u in JSON at position 0 #270

Open
rolivares opened this issue Apr 7, 2021 · 2 comments
Open

Unexpected token u in JSON at position 0 #270

rolivares opened this issue Apr 7, 2021 · 2 comments

Comments

@rolivares
Copy link

this error is shown on console when I upgrade to v0.40 and execute the linter, is not currently appearing on 0.39

maybe related about 'response-error-response-schema' that appearing on revision too, using the same definition

SyntaxError: Unexpected token u in JSON at position 0 at JSON.parse (<anonymous>) at Object.json-schema-validation (eval at exports.evaluateExport (C:\GIT\MTT\bono\back\node_modules\@stoplight\spectral\dist\rulesets\evaluators.js:89:80), <anonymous>:12:27) at Object.exports.lintNode (C:\GIT\MTT\bono\back\node_modules\@stoplight\spectral\dist\runner\lintNode.js:30:33) at callback (C:\GIT\MTT\bono\back\node_modules\@stoplight\spectral\dist\runner\runner.js:38:32) at JSONPath._handleCallback (C:\GIT\MTT\bono\back\node_modules\jsonpath-plus\dist\index-umd.js:626:7) at JSONPath._trace (C:\GIT\MTT\bono\back\node_modules\jsonpath-plus\dist\index-umd.js:658:12) at JSONPath._trace (C:\GIT\MTT\bono\back\node_modules\jsonpath-plus\dist\index-umd.js:733:19) at JSONPath.evaluate (C:\GIT\MTT\bono\back\node_modules\jsonpath-plus\dist\index-umd.js:566:23) at new JSONPath (C:\GIT\MTT\bono\back\node_modules\jsonpath-plus\dist\index-umd.js:498:22) at Object.JSONPath (C:\GIT\MTT\bono\back\node_modules\jsonpath-plus\dist\index-umd.js:452:16)

@alecor191
Copy link

alecor191 commented Apr 11, 2021

I'm getting the same error using the following command:

lint-openapi -v -j -p --debug 'D:\temp\my-openapi-spec.json'

Output:

[Warning] Skipping non-existent file: D:\temp\my-openapi-spec.json
SyntaxError: Unexpected token u in JSON at position 0
    at JSON.parse (<anonymous>)
    at Object.json-schema-validation (eval at exports.evaluateExport (C:\Users\aleco\AppData\Roaming\npm\node_modules\ibm-openapi-validator\node_modules\@stoplight\spectral\dist\rulesets\evaluators.js:89:80), <anonymous>:12:27)
    at Object.exports.lintNode (C:\Users\aleco\AppData\Roaming\npm\node_modules\ibm-openapi-validator\node_modules\@stoplight\spectral\dist\runner\lintNode.js:30:33)
    at callback (C:\Users\aleco\AppData\Roaming\npm\node_modules\ibm-openapi-validator\node_modules\@stoplight\spectral\dist\runner\runner.js:38:32)
    at JSONPath._handleCallback (C:\Users\aleco\AppData\Roaming\npm\node_modules\ibm-openapi-validator\node_modules\jsonpath-plus\dist\index-umd.js:626:7)
    at JSONPath._trace (C:\Users\aleco\AppData\Roaming\npm\node_modules\ibm-openapi-validator\node_modules\jsonpath-plus\dist\index-umd.js:658:12)
    at JSONPath._trace (C:\Users\aleco\AppData\Roaming\npm\node_modules\ibm-openapi-validator\node_modules\jsonpath-plus\dist\index-umd.js:733:19)
    at JSONPath.evaluate (C:\Users\aleco\AppData\Roaming\npm\node_modules\ibm-openapi-validator\node_modules\jsonpath-plus\dist\index-umd.js:566:23)
    at new JSONPath (C:\Users\aleco\AppData\Roaming\npm\node_modules\ibm-openapi-validator\node_modules\jsonpath-plus\dist\index-umd.js:498:22)
    at Object.JSONPath (C:\Users\aleco\AppData\Roaming\npm\node_modules\ibm-openapi-validator\node_modules\jsonpath-plus\dist\index-umd.js:452:16)
{
  "version": "0.40.1",
  "warnings": [
    {
      "path": [],
      "message": "OpenAPI `servers` must be present and non-empty array.",
      "rule": "oas3-api-servers",
      "line": 0
    },
    {
      "path": [],
      "message": "OpenAPI object should have non-empty `tags` array.",
      "rule": "openapi-tags",
      "line": 0
    },
...

Worth mentioning:

  • Even though I get the error+callstack above, the file still seems to get validated, as I see warnings/errors printed after the exception call stack (see output above).
  • If I use the openapi-validator's Docker container, then it works fine (I'm pointing it to the same file)

Environment info

  • openapi-validator: 0.40.1
  • Win10
  • NPM version:
    {
      npm: '7.9.0',
      node: '15.13.0',
      v8: '8.6.395.17-node.28',
      uv: '1.41.0',
      zlib: '1.2.11',
      brotli: '1.0.9',
      ares: '1.17.1',
      modules: '88',
      nghttp2: '1.42.0',
      napi: '8',
      llhttp: '2.1.3',
      openssl: '1.1.1j+quic',
      cldr: '38.1',
      icu: '68.2',
      tz: '2020d',
      unicode: '13.0',
      ngtcp2: '0.1.0-DEV',
      nghttp3: '0.1.0-DEV'
    }
    

@dpopp07
Copy link
Member

dpopp07 commented Aug 9, 2022

This seems to be a Windows-specific issue with the tool. Is this still happening on the latest version?

@rolivares @alecor191

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

No branches or pull requests

4 participants