Skip to content
This repository was archived by the owner on May 8, 2025. It is now read-only.
This repository was archived by the owner on May 8, 2025. It is now read-only.

npm_and_yarn json parse error #526

@peijianju

Description

@peijianju

Deaer dependabot-script team,
We are experiencing some issue with dependabot/dependabot-core image and its scripts

symptoms

We saw this error in our pipeline,

/home/dependabot/dependabot-script/vendor/ruby/2.6.0/gems/dependabot-common-0.118.8/lib/dependabot/shared_helpers.rb:116:in `rescue in run_helper_subprocess': Dependabot::SharedHelpers::HelperSubprocessFailed
	from /home/dependabot/dependabot-script/vendor/ruby/2.6.0/gems/dependabot-common-0.118.8/lib/dependabot/shared_helpers.rb:84:in `run_helper_subprocess'
	...
	from /home/dependabot/dependabot-script/vendor/ruby/2.6.0/gems/dependabot-npm_and_yarn-0.118.8/lib/dependabot/npm_and_yarn/file_updater.rb:39:in `updated_dependency_files'
	from ./generic-update-script.rb:212:in `block in <main>'
	from ./generic-update-script.rb:174:in `each'
	from ./generic-update-script.rb:174:in `<main>'
/usr/lib/ruby/2.6.0/json/common.rb:156:in `parse': 767: unexpected token at '' (JSON::ParserError)
	from /usr/lib/ruby/2.6.0/json/common.rb:156:in `parse'

We used the latest dependabot/dependabot-core image. so I think the latest dependabot/dependabot-core is broken

root cause suspects

Further investigation point me to this file shared_helpers.rb and this line

response = JSON.parse(stdout)

By printing the stderr in shared_helpers.rb I found this

Error: Cannot find module './lib/npm'
Require stack:
- /opt/npm_and_yarn/run.js
    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:880:15)
    at Function.Module._load (internal/modules/cjs/loader.js:725:27)
    at Module.require (internal/modules/cjs/loader.js:952:19)
    at require (internal/modules/cjs/helpers.js:88:18)
    at Socket.<anonymous> (/opt/npm_and_yarn/run.js:12:19)
    at Socket.emit (events.js:327:22)
    at endReadableNT (internal/streams/readable.js:1327:12)
    at processTicksAndRejections (internal/process/task_queues.js:80:21) {
  code: 'MODULE_NOT_FOUND',
  requireStack: [ '/opt/npm_and_yarn/run.js' ]
}

By inspecting the image file, I found this

root@301c0231d8c2:/home/dependabot/dependabot-script# ls /opt/npm_and_yarn/lib/
npm6  yarn

So is /opt/npm_and_yarn/run.js expecting npm instead of npm6 ?

Thank you

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions