microsoft / beachball

The Sunniest Semantic Version Bumper

Home Page:https://microsoft.github.io/beachball

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

JSON parse failure when `npm show` output is an empty string and 0 exit code

adrewb opened this issue Β· comments

πŸ› Description

The npm show --registry <registry> --json <packageName> produced empty output with a 0 exit code in certain cases. Beachball assumes valid JSON output on a 0 exit code and attempts to parse the stdout stream. I caused this problem by manually fixing a package in AWS CodeArtifact, which changed the expected output returned by npm show. I was able to fix beachball's behavior by adding showResult.stdout !== '' check on the listPackageVersions.ts success case. Arguably, this is a bug with npm show --json which does not produce valid JSON with a 0 exit code.

πŸ€– Environment

AWS CodeArtifact Registry
Beachball v2.23.0
Node 14.19.3

I verified that npm show --json produced empty output for this particular registry and package.

πŸ”’ Error Output

Removing change path
An error has been detected while running beachball!
SyntaxError: Unexpected end of JSON input
    at JSON.parse (<anonymous>)
    at /home/runner/work/dexible-infra/dexible-infra/node_modules/beachball/lib/packageManager/listPackageVersions.js:26:42
    at Generator.next (<anonymous>)
    at fulfilled (/home/runner/work/dexible-infra/dexible-infra/node_modules/beachball/lib/packageManager/listPackageVersions.js:5:58)
    at processTicksAndRejections (internal/process/task_queues.js:95:5)
beachball v2.23.0 - the sunniest version bumping tool