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

fix NPE if dependencies fields are explicitly null in get-dep-spec #5

Closed
wants to merge 1 commit into from

Conversation

adrienbaron
Copy link

@adrienbaron adrienbaron commented Mar 16, 2021

This fixes an NPE that happens when a project doesn't have a dependencies field in it's package.json on GitHub private packages repository.

In that case, the GitHub repository API returns dependencies explicitly to null, which means the default value assignment in lib/get-dep-spec.js doesn't kick in, and the process just crashes with an NPE.
This makes npm audit in npm 7 crash if you depend on a package hosted on GitHub private packages repository that has any version in it's history with no dependencies field.

This also cannot be fixed by pushing a new version to the repository as old versions will still return dependencies: null.

This is not a breaking change, and is just a safer behaviour than previously.

Sample response from GitHub private repository

When calling: https://npm.pkg.github.com/REDACTED_PACKAGE_NAME

{
  "name": "REDACTED_PACKAGE_NAME",
  "dist-tags": {
    "latest": "12.0.2"
  },
  "versions": {
    "10.14.6": {
      "dependencies": null,

@wraithgar
Copy link
Member

Closed here #6

Sorry we didn't notice this first.

@wraithgar wraithgar closed this Mar 26, 2021
@adrienbaron
Copy link
Author

It's OK, happy it's fixed 👍

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

Successfully merging this pull request may close these issues.

2 participants