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

pnpm audit  failed with: ERROR  Cannot read properties of undefined (reading 'metadata') #5200

Closed
timtong1982 opened this issue Aug 11, 2022 · 4 comments · Fixed by #5246
Milestone

Comments

@timtong1982
Copy link
Contributor

pnpm version:

6.32.9
tested 7.9.0 as well, same

Code to reproduce the issue:

mono repo with pnpm-workspace.yaml

Expected behavior:

Show audit result

Actual behavior:

 ERROR  Cannot read properties of undefined (reading 'metadata')

Additional information:

  • node -v prints: v16.15.1
  • Windows, macOS, or Linux?: macOS
@Shinyaigeek
Copy link
Member

I cannot reproduce this error with v7.9.3. Can you share the repository or stackblitz for reproduction?

@timtong1982
Copy link
Contributor Author

The root cause is

I am using a private az npm registry which doesn't have audit endpoint, this will lead a 404 error on getting the AuditReport

the catch part of that function doesn't process this error as well, so the code will goes down all the way to
const vulnerabilities = auditReport.metadata.vulnerabilities;
and then this error pops

@timtong1982
Copy link
Contributor Author

https://github.com/pnpm/pnpm/blob/8103f92bd60d80b1e880cbb46bdd43c038024076/packages/plugin-commands-audit/src/audit.ts

this issue is still there, I think we need capture the 404 error in the

} catch (err: any) { // eslint-disable-line
    if (opts.ignoreRegistryErrors) {
      return {
        exitCode: 0,
        output: err.message,
      }
    }
  }

@timtong1982
Copy link
Contributor Author

PR added:
#5246

@zkochan zkochan added this to the v7.9 milestone Aug 23, 2022
zkochan pushed a commit that referenced this issue Aug 23, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants