Skip to content

Better NPM error handling #820

@leventebalogh

Description

@leventebalogh

What's the problem?

In case we have NPM errors (e.g. here), we have an empty output, which results in an empty github PR comment in the dependant workflows.

Example NPM error

grafana-data
=================================================
npm warn exec The following package was not found and will be installed: @grafana/[email protected]
npm error code E403
npm error 403 403 Forbidden - GET https://registry.npmjs.org/decamelize/-/decamelize-1.2.0.tgz
npm error 403 In most cases, you or one of your dependencies are requesting
npm error 403 a package version that is forbidden by your security policy, or
npm error 403 on a server you do not have access to.
npm error A complete log of this run can be found in: /home/runner/.npm/_logs/2025-04-01T15_51_16_595Z-debug-0.log
undefined:1


SyntaxError: Unexpected end of JSON input
    at JSON.parse (<anonymous>)
    at Object.<anonymous> (/home/runner/work/grafana/grafana/scripts/levitate-parse-json-report.js:5:19)
    at Module._compile (node:internal/modules/cjs/loader:1546:14)
    at Object..js (node:internal/modules/cjs/loader:1689:10)
    at Module.load (node:internal/modules/cjs/loader:1318:32)
    at Function._load (node:internal/modules/cjs/loader:1128:12)
    at TracingChannel.traceSync (node:diagnostics_channel:315:14)
    at wrapModuleLoad (node:internal/modules/cjs/loader:218:24)
    at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:170:5)
    at node:internal/main/run_main_module:36:49

Node.js v22.11.0

Possible solution?

Surface if there are any errors during the NPM installs (or during any other "setup" task), so the call-site doesn't think there are no breaking changes found.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    Status

    📅 Planned

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions