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

[BUG] npm unpublish outputs OK | 0 | 200 when package version doesn't exist #7650

Open
2 tasks done
AllanOricil opened this issue Jul 15, 2024 · 6 comments
Open
2 tasks done
Labels
Bug thing that needs fixing Priority 2 secondary priority issue

Comments

@AllanOricil
Copy link

AllanOricil commented Jul 15, 2024

Is there an existing issue for this?

  • I have searched the existing issues

This issue exists in the latest npm version

  • I am using the latest npm

Current Behavior

I just published v0.2.1 and I can't unpublish it. (less than 72h)

npm unpublish @namespace/package-name@vx.x.x -f does not throw exception, but does not work. I unpublished my package and it still present in npm. Because of that, I can't publish that version again

image

no error message, and this unpublish command doesn't work, even after npm login

image

Expected Behavior

at least an exception should appear if I can't unpublish a package

Steps To Reproduce

  1. publish a package with namespace (e.g. @namespace)
  2. wait it to appear on npm
  3. run npm unpublish @namespace/package-name@vx.x.x -f
  4. verify no error appears on the terminal
  5. verify npm is still showing the package, even after days have passed
  6. verify that you can't publish the same version

Environment

//journeylab-tech-845044614340.d.codeartifact.us-east-2.amazonaws.com/npm/flowfuse/:_authToken = (protected)
//journeylab-tech-845044614340.d.codeartifact.us-east-2.amazonaws.com/npm/node-ready/:_authToken = (protected)
//registry.npmjs.org/:_authToken = (protected)
registry = "https://registry.npmjs.org"

; "project" config from /Users/ec2-user/node-ready-ascend-data-storage/.npmrc

@node-ready:registry = "https://registry.npmjs.org/"

; node bin location = /Users/ec2-user/.nvm/versions/node/v18.19.1/bin/node
; node version = v18.19.1
; npm local prefix = /Users/ec2-user/node-ready-ascend-data-storage
; npm version = 10.2.4
; cwd = /Users/ec2-user/node-ready-ascend-data-storage
; HOME = /Users/ec2-user
; Run npm config ls -l to show all defaults.

@AllanOricil AllanOricil added Bug thing that needs fixing Needs Triage needs review for next steps labels Jul 15, 2024
@AllanOricil
Copy link
Author

I can't understand how a simple feature like this keeps breaking. I updated npm to the 10.8.2 and tried to unpublish the whole package and just a version

image

and again it did not work...

@milaninfy
Copy link
Contributor

milaninfy commented Aug 2, 2024

@AllanOricil I tested and it's working as expected. I believe could you please check the syntax npm unpublish @namespace/package-name@x.x.x not include v in the version specification so e.g. npm unpublish @namespace/package-name@1.2.3

~/workarea/rep/testpkg $ npm view @myscope/testpkg versions
[ '1.2.0', '1.3.0' ]
~/workarea/rep/testpkg $ npm unpublish @myscope/testpkg@1.2.0
- @myscope/testpkg@1.2.0
~/workarea/rep/testpkg $ npm view @myscope/testpkg versions
1.3.0
~/workarea/rep/testpkg $ npm unpublish @myscope/testpkg -f   
npm warn using --force Recommended protections disabled.
- @milansmeva/testpkg
~/workarea/rep/testpkg $ npm view @myscope/testpkg versions
npm error code E404
npm error 404 Unpublished on 2024-08-02T21:21:51.311Z
npm error 404
npm error 404  '@myscope/testpkg' is not in this registry.
npm error 404
npm error 404 Note that you can also install from a
npm error 404 tarball, folder, http url, or git url.
npm error A complete log of this run can be found in: /Users/milaninfy/.npm/_logs/2024-08-02T21_22_07_744Z-debug-0.log

@AllanOricil
Copy link
Author

AllanOricil commented Aug 2, 2024

@milaninfy
it is clearly not working as expected. If the version is wrong, or doesn't exist, it should tell "HEY IT IS WRONG!" and exit with 1 instead of 0.

image

@milaninfy milaninfy added Priority 2 secondary priority issue and removed Needs Triage needs review for next steps labels Aug 9, 2024
@milaninfy
Copy link
Contributor

Behaviour is by design here, It exits correctly with code 0 if the version doesn't exist then it's effectively gone, however a logging would be useful here if the version doesn't exit.

@AllanOricil
Copy link
Author

AllanOricil commented Aug 9, 2024

@milaninfy so NPM by design displays 200, OK and exit 0 when UMPUBLISH fails? weird.

  • How can a User know umpublish failed?
    even with --verbose, there is no way he can know it didn't work unless he/she opens NPM UI

  • How can a CI job know umpublish failed, and then display failure?
    can you give an example showing how to handle this type of error using major CI environments, like Github Actions?
    I have a Github Actions Workflow with an input for the package version. User can provide anything in that input. If User provides a version that doesn't exist, my CI Workflow will finish with Success. Does it make sense for you or @shadowspawn?

This is clearly a new known error type "UNKNOWN VERSION" which has to be treated as: 400, NOT OK, 1

@shadowspawn
Copy link
Contributor

Hi @AllanOricil

I gave a thumbs-up to the comment which diagnosed the error in the command you were running. I had read your description (thanks for the clear description) but hadn't spotted the extra v. I wasn't offering an opinion on whether the behaviour was ideal.

I appreciate the lack of clues provided by the unpublish caused you some confusion and cost you some time.

Perhaps you could change the title of this issue to more accurately describe what turned out to be the problem.

@AllanOricil AllanOricil changed the title [BUG] npm unpublish doesnt work [BUG] npm unpublish wrongly ackowledges that package was unpublished Aug 9, 2024
@AllanOricil AllanOricil changed the title [BUG] npm unpublish wrongly ackowledges that package was unpublished [BUG] npm unpublish says 200 when package version doesnt exist Aug 10, 2024
@AllanOricil AllanOricil changed the title [BUG] npm unpublish says 200 when package version doesnt exist [BUG] npm unpublish outputs OK when package version doesn't exist Aug 10, 2024
@AllanOricil AllanOricil changed the title [BUG] npm unpublish outputs OK when package version doesn't exist [BUG] npm unpublish outputs OK | 0 | 200 when package version doesn't exist Aug 10, 2024
@milaninfy milaninfy assigned milaninfy and unassigned milaninfy Sep 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug thing that needs fixing Priority 2 secondary priority issue
Projects
None yet
Development

No branches or pull requests

3 participants