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

[BUG] Extractor - Spectral Linting no longer working with node 12.x #557

Closed
vandriot opened this issue Jun 4, 2024 · 3 comments
Closed

Comments

@vandriot
Copy link
Contributor

vandriot commented Jun 4, 2024

Release version

v5.1.4

Describe the bug

Hello,

I recently noticed that the Spectral Linting tool is no longer working when running the extractor, see errors I'm getting below.
I'm using Azure DevOps agents with Ubuntu 22.04.4 to run the pipeline.

==============================================================================
Task         : Command line
Description  : Run a command line script using Bash on Linux and macOS and cmd.exe on Windows
Version      : 2.237.1
Author       : Microsoft Corporation
Help         : https://docs.microsoft.com/azure/devops/pipelines/tasks/utility/command-line
==============================================================================
Generating script.
Script contents:
spectral lint --format stylish --format junit --output.junit /home/vsts/work/1/a/spectral-result.xml /home/vsts/work/1/a/artifacts/apis/**/specification.{json,yaml,yml} -r https://raw.githubusercontent.com/connectedcircuits/devops-api-linter/main/rules.yaml
========================== Starting Command Output ===========================
[command]/usr/bin/bash --noprofile --norc /home/vsts/work/_temp/61ee25b7-04cb-4fce-80e0-123aed7526ea.sh
internal/modules/cjs/loader.js:818
  throw err;
  ^

Error: Cannot find module 'node:url'
Require stack:
- /opt/hostedtoolcache/node/12.22.12/x64/lib/node_modules/@stoplight/spectral-cli/node_modules/fast-uri/index.js
- /opt/hostedtoolcache/node/12.22.12/x64/lib/node_modules/@stoplight/spectral-cli/node_modules/ajv/dist/runtime/uri.js
- /opt/hostedtoolcache/node/12.22.12/x64/lib/node_modules/@stoplight/spectral-cli/node_modules/ajv/dist/core.js
- /opt/hostedtoolcache/node/12.22.12/x64/lib/node_modules/@stoplight/spectral-cli/node_modules/ajv/dist/ajv.js
- /opt/hostedtoolcache/node/12.22.12/x64/lib/node_modules/@stoplight/spectral-cli/node_modules/@stoplight/spectral-core/dist/ruleset/validation/ajv.js
- /opt/hostedtoolcache/node/12.22.12/x64/lib/node_modules/@stoplight/spectral-cli/node_modules/@stoplight/spectral-core/dist/ruleset/validation/assertions.js
- /opt/hostedtoolcache/node/12.22.12/x64/lib/node_modules/@stoplight/spectral-cli/node_modules/@stoplight/spectral-core/dist/ruleset/validation/index.js
- /opt/hostedtoolcache/node/12.22.12/x64/lib/node_modules/@stoplight/spectral-cli/node_modules/@stoplight/spectral-core/dist/ruleset/ruleset.js
- /opt/hostedtoolcache/node/12.22.12/x64/lib/node_modules/@stoplight/spectral-cli/node_modules/@stoplight/spectral-core/dist/spectral.js
- /opt/hostedtoolcache/node/12.22.12/x64/lib/node_modules/@stoplight/spectral-cli/node_modules/@stoplight/spectral-core/dist/index.js
- /opt/hostedtoolcache/node/12.22.12/x64/lib/node_modules/@stoplight/spectral-cli/dist/commands/lint.js
- /opt/hostedtoolcache/node/12.22.12/x64/lib/node_modules/@stoplight/spectral-cli/dist/index.js
    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:815:15)
    at Function.Module._load (internal/modules/cjs/loader.js:667:27)
    at Module.require (internal/modules/cjs/loader.js:887:19)
    at require (internal/modules/cjs/helpers.js:74:18)
    at Object.<anonymous> (/opt/hostedtoolcache/node/12.22.12/x64/lib/node_modules/@stoplight/spectral-cli/node_modules/fast-uri/index.js:3:13)
    at Module._compile (internal/modules/cjs/loader.js:999:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1027:10)
    at Module.load (internal/modules/cjs/loader.js:863:32)
    at Function.Module._load (internal/modules/cjs/loader.js:708:14)
    at Module.require (internal/modules/cjs/loader.js:887:19) {
  code: 'MODULE_NOT_FOUND',
  requireStack: [
    '/opt/hostedtoolcache/node/12.22.12/x64/lib/node_modules/@stoplight/spectral-cli/node_modules/fast-uri/index.js',
    '/opt/hostedtoolcache/node/12.22.12/x64/lib/node_modules/@stoplight/spectral-cli/node_modules/ajv/dist/runtime/uri.js',
    '/opt/hostedtoolcache/node/12.22.12/x64/lib/node_modules/@stoplight/spectral-cli/node_modules/ajv/dist/core.js',
    '/opt/hostedtoolcache/node/12.22.12/x64/lib/node_modules/@stoplight/spectral-cli/node_modules/ajv/dist/ajv.js',
    '/opt/hostedtoolcache/node/12.22.12/x64/lib/node_modules/@stoplight/spectral-cli/node_modules/@stoplight/spectral-core/dist/ruleset/validation/ajv.js',
    '/opt/hostedtoolcache/node/12.22.12/x64/lib/node_modules/@stoplight/spectral-cli/node_modules/@stoplight/spectral-core/dist/ruleset/validation/assertions.js',
    '/opt/hostedtoolcache/node/12.22.12/x64/lib/node_modules/@stoplight/spectral-cli/node_modules/@stoplight/spectral-core/dist/ruleset/validation/index.js',
    '/opt/hostedtoolcache/node/12.22.12/x64/lib/node_modules/@stoplight/spectral-cli/node_modules/@stoplight/spectral-core/dist/ruleset/ruleset.js',
    '/opt/hostedtoolcache/node/12.22.12/x64/lib/node_modules/@stoplight/spectral-cli/node_modules/@stoplight/spectral-core/dist/spectral.js',
    '/opt/hostedtoolcache/node/12.22.12/x64/lib/node_modules/@stoplight/spectral-cli/node_modules/@stoplight/spectral-core/dist/index.js',
    '/opt/hostedtoolcache/node/12.22.12/x64/lib/node_modules/@stoplight/spectral-cli/dist/commands/lint.js',
    '/opt/hostedtoolcache/node/12.22.12/x64/lib/node_modules/@stoplight/spectral-cli/dist/index.js'
  ]
}

##[error]Bash exited with code '1'.
##[error]Bash wrote one or more lines to the standard error stream.
##[error]internal/modules/cjs/loader.js:818
  throw err;
  ^

Error: Cannot find module 'node:url'
Require stack:
- /opt/hostedtoolcache/node/12.22.12/x64/lib/node_modules/@stoplight/spectral-cli/node_modules/fast-uri/index.js
- /opt/hostedtoolcache/node/12.22.12/x64/lib/node_modules/@stoplight/spectral-cli/node_modules/ajv/dist/runtime/uri.js
- /opt/hostedtoolcache/node/12.22.12/x64/lib/node_modules/@stoplight/spectral-cli/node_modules/ajv/dist/core.js
- /opt/hostedtoolcache/node/12.22.12/x64/lib/node_modules/@stoplight/spectral-cli/node_modules/ajv/dist/ajv.js
- /opt/hostedtoolcache/node/12.22.12/x64/lib/node_modules/@stoplight/spectral-cli/node_modules/@stoplight/spectral-core/dist/ruleset/validation/ajv.js
- /opt/hostedtoolcache/node/12.22.12/x64/lib/node_modules/@stoplight/spectral-cli/node_modules/@stoplight/spectral-core/dist/ruleset/validation/assertions.js
- /opt/hostedtoolcache/node/12.22.12/x64/lib/node_modules/@stoplight/spectral-cli/node_modules/@stoplight/spectral-core/dist/ruleset/validation/index.js
- /opt/hostedtoolcache/node/12.22.12/x64/lib/node_modules/@stoplight/spectral-cli/node_modules/@stoplight/spectral-core/dist/ruleset/ruleset.js
- /opt/hostedtoolcache/node/12.22.12/x64/lib/node_modules/@stoplight/spectral-cli/node_modules/@stoplight/spectral-core/dist/spectral.js
- /opt/hostedtoolcache/node/12.22.12/x64/lib/node_modules/@stoplight/spectral-cli/node_modules/@stoplight/spectral-core/dist/index.js
- /opt/hostedtoolcache/node/12.22.12/x64/lib/node_modules/@stoplight/spectral-cli/dist/commands/lint.js
- /opt/hostedtoolcache/node/12.22.12/x64/lib/node_modules/@stoplight/spectral-cli/dist/index.js
    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:815:15)
    at Function.Module._load (internal/modules/cjs/loader.js:667:27)
    at Module.require (internal/modules/cjs/loader.js:887:19)
    at require (internal/modules/cjs/helpers.js:74:18)
    at Object.<anonymous> (/opt/hostedtoolcache/node/12.22.12/x64/lib/node_modules/@stoplight/spectral-cli/node_modules/fast-uri/index.js:3:13)
    at Module._compile (internal/modules/cjs/loader.js:999:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1027:10)
    at Module.load (internal/modules/cjs/loader.js:863:32)
    at Function.Module._load (internal/modules/cjs/loader.js:708:14)
    at Module.require (internal/modules/cjs/loader.js:887:19) {
  code: 'MODULE_NOT_FOUND',
  requireStack: [
    '/opt/hostedtoolcache/node/12.22.12/x64/lib/node_modules/@stoplight/spectral-cli/node_modules/fast-uri/index.js',
    '/opt/hostedtoolcache/node/12.22.12/x64/lib/node_modules/@stoplight/spectral-cli/node_modules/ajv/dist/runtime/uri.js',
    '/opt/hostedtoolcache/node/12.22.12/x64/lib/node_modules/@stoplight/spectral-cli/node_modules/ajv/dist/core.js',
    '/opt/hostedtoolcache/node/12.22.12/x64/lib/node_modules/@stoplight/spectral-cli/node_modules/ajv/dist/ajv.js',
    '/opt/hostedtoolcache/node/12.22.12/x64/lib/node_modules/@stoplight/spectral-cli/node_modules/@stoplight/spectral-core/dist/ruleset/validation/ajv.js',
    '/opt/hostedtoolcache/node/12.22.12/x64/lib/node_modules/@stoplight/spectral-cli/node_modules/@stoplight/spectral-core/dist/ruleset/validation/assertions.js',
    '/opt/hostedtoolcache/node/12.22.12/x64/lib/node_modules/@stoplight/spectral-cli/node_modules/@stoplight/spectral-core/dist/ruleset/validation/index.js',
    '/opt/hostedtoolcache/node/12.22.12/x64/lib/node_modules/@stoplight/spectral-cli/node_modules/@stoplight/spectral-core/dist/ruleset/ruleset.js',
    '/opt/hostedtoolcache/node/12.22.12/x64/lib/node_modules/@stoplight/spectral-cli/node_modules/@stoplight/spectral-core/dist/spectral.js',
    '/opt/hostedtoolcache/node/12.22.12/x64/lib/node_modules/@stoplight/spectral-cli/node_modules/@stoplight/spectral-core/dist/index.js',
    '/opt/hostedtoolcache/node/12.22.12/x64/lib/node_modules/@stoplight/spectral-cli/dist/commands/lint.js',
    '/opt/hostedtoolcache/node/12.22.12/x64/lib/node_modules/@stoplight/spectral-cli/dist/index.js'
  ]
}

  throw err;
  ^

Error: Cannot find module 'node:url'
Require stack:
- /opt/hostedtoolcache/node/12.22.12/x64/lib/node_modules/@stoplight/spectral-cli/node_modules/fast-uri/index.js
- /opt/hostedtoolcache/node/12.22.12/x64/lib/node_modules/@stoplight/spectral-cli/node_modules/ajv/dist/runtime/uri.js
- /opt/hostedtoolcache/node/12.22.12/x64/lib/node_modules/@stoplight/spectral-cli/node_modules/ajv/dist/core.js
- /opt/hostedtoolcache/node/12.22.12/x64/lib/node_modules/@stoplight/spectral-cli/node_modules/ajv/dist/ajv.js
- /opt/hostedtoolcache/node/12.22.12/x64/lib/node_modules/@stoplight/spectral-cli/node_modules/@stoplight/spectral-core/dist/ruleset/validation/ajv.js
- /opt/hostedtoolcache/node/12.22.12/x64/lib/node_modules/@stoplight/spectral-cli/node_modules/@stoplight/spectral-core/dist/ruleset/validation/assertions.js
- /opt/hostedtoolcache/node/12.22.12/x64/lib/node_modules/@stoplight/spectral-cli/node_modules/@stoplight/spectral-core/dist/ruleset/validation/index.js
- /opt/hostedtoolcache/node/12.22.12/x64/lib/node_modules/@stoplight/spectral-cli/node_modules/@stoplight/spectral-core/dist/ruleset/ruleset.js
- /opt/hostedtoolcache/node/12.22.12/x64/lib/node_modules/@stoplight/spectral-cli/node_modules/@stoplight/spectral-core/dist/spectral.js
- /opt/hostedtoolcache/node/12.22.12/x64/lib/node_modules/@stoplight/spectral-cli/node_modules/@stoplight/spectral-core/dist/index.js
- /opt/hostedtoolcache/node/12.22.12/x64/lib/node_modules/@stoplight/spectral-cli/dist/commands/lint.js
- /opt/hostedtoolcache/node/12.22.12/x64/lib/node_modules/@stoplight/spectral-cli/dist/index.js
    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:815:15)
    at Function.Module._load (internal/modules/cjs/loader.js:667:27)
    at Module.require (internal/modules/cjs/loader.js:887:19)
    at require (internal/modules/cjs/helpers.js:74:18)
    at Object.<anonymous> (/opt/hostedtoolcache/node/12.22.12/x64/lib/node_modules/@stoplight/spectral-cli/node_modules/fast-uri/index.js:3:13)
    at Module._compile (internal/modules/cjs/loader.js:999:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1027:10)
    at Module.load (internal/modules/cjs/loader.js:863:32)
    at Function.Module._load (internal/modules/cjs/loader.js:708:14)
    at Module.require (internal/modules/cjs/loader.js:887:19) {
  code: 'MODULE_NOT_FOUND',
  requireStack: [
    '/opt/hostedtoolcache/node/12.22.12/x64/lib/node_modules/@stoplight/spectral-cli/node_modules/fast-uri/index.js',
    '/opt/hostedtoolcache/node/12.22.12/x64/lib/node_modules/@stoplight/spectral-cli/node_modules/ajv/dist/runtime/uri.js',
    '/opt/hostedtoolcache/node/12.22.12/x64/lib/node_modules/@stoplight/spectral-cli/node_modules/ajv/dist/core.js',
    '/opt/hostedtoolcache/node/12.22.12/x64/lib/node_modules/@stoplight/spectral-cli/node_modules/ajv/dist/ajv.js',
    '/opt/hostedtoolcache/node/12.22.12/x64/lib/node_modules/@stoplight/spectral-cli/node_modules/@stoplight/spectral-core/dist/ruleset/validation/ajv.js',
    '/opt/hostedtoolcache/node/12.22.12/x64/lib/node_modules/@stoplight/spectral-cli/node_modules/@stoplight/spectral-core/dist/ruleset/validation/assertions.js',
    '/opt/hostedtoolcache/node/12.22.12/x64/lib/node_modules/@stoplight/spectral-cli/node_modules/@stoplight/spectral-core/dist/ruleset/validation/index.js',
    '/opt/hostedtoolcache/node/12.22.12/x64/lib/node_modules/@stoplight/spectral-cli/node_modules/@stoplight/spectral-core/dist/ruleset/ruleset.js',
    '/opt/hostedtoolcache/node/12.22.12/x64/lib/node_modules/@stoplight/spectral-cli/node_modules/@stoplight/spectral-core/dist/spectral.js',
    '/opt/hostedtoolcache/node/12.22.12/x64/lib/node_modules/@stoplight/spectral-cli/node_modules/@stoplight/spectral-core/dist/index.js',
    '/opt/hostedtoolcache/node/12.22.12/x64/lib/node_modules/@stoplight/spectral-cli/dist/commands/lint.js',
    '/opt/hostedtoolcache/node/12.22.12/x64/lib/node_modules/@stoplight/spectral-cli/dist/index.js'
  ]
}
##[section]Finishing: Run Spectral Linting

I think the issue come from the version of Node that the pipeline is using (v12.x).
I tried to use the LTS version of Node (v20.x) and it fixes the issue.

I propose to update the version of Node used in the azdo pipeline to v20.x, I'll create a PR for that.

Expected behavior

We should have the result of the Spectral Lint displayed in the logs.

Actual behavior

Spectral lint doesn't run.

Reproduction Steps

Launch the Extractor pipeline and check the result of Run Spectral Linting step

Copy link

github-actions bot commented Jun 4, 2024

  Thank you for opening this issue! Please be patient while we will look into it and get back to you as this is an open source project. In the meantime make sure you take a look at the [closed issues](https://github.com/Azure/apiops/issues?q=is%3Aissue+is%3Aclosed) in case your question has already been answered. Don't forget to provide any additional information if needed (e.g. scrubbed logs, detailed feature requests,etc.).
  Whenever it's feasible, please don't hesitate to send a Pull Request (PR) our way. We'd greatly appreciate it, and we'll gladly assess and incorporate your changes.

@waelkdouh
Copy link
Contributor

Thanks for the pr. Once we are done testing v6 release we will take a look at this.

@vandriot
Copy link
Contributor Author

Closing ticket as #558 is merged

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

2 participants