Skip to content

Deprecate npm packages doesn't work with mixed payload

Everyone can contribute. Help move this issue forward while earning points, leveling up and collecting rewards.

Description

The Packages::Npm::DeprecatePackageService doesn't work correctly with the mixed payload.

Example:

I've published multiple package versions and deprecated some of them. Now I want to un-deprecate one of the version: 4.0.0

In this case JSON payload will look like:

{"name"=>"@packages/sample",
 "versions"=>
  {"2.0.0"=>
    {"deprecated"=>"Deprecated",
     "dist"=>{"shasum"=>"9e906990d3ac313377024c4f389ab128db8d301f", "tarball"=>"http://gdk.test:3000/api/v4/projects/19/packages/npm/@packages/sample/-/@packages/sample-2.0.0.tgz"},
     "name"=>"@packages/sample",
     "version"=>"2.0.0"},
   "3.0.0"=>
    {"deprecated"=>"Deprecated",
     "dist"=>{"shasum"=>"4da0725fde1cf9f3c5971a093fe0016c1024b3f9", "tarball"=>"http://gdk.test:3000/api/v4/projects/19/packages/npm/@packages/sample/-/@packages/sample-3.0.0.tgz"},
     "name"=>"@packages/sample",
     "version"=>"3.0.0"},
   "4.0.0"=>
    {"deprecated"=>"",
     "dist"=>{"shasum"=>"cdd276904be279f930a3beb0fe414c16c009b6ed", "tarball"=>"http://gdk.test:3000/api/v4/projects/19/packages/npm/@packages/sample/-/@packages/sample-4.0.0.tgz"},
     "name"=>"@packages/sample",
     "version"=>"4.0.0"},
   "1.0.0"=>
    {"deprecated"=>"Deprecated",
     "dist"=>{"shasum"=>"f428c3c9fae7430deea68f547c542b959eea4ccf", "tarball"=>"http://gdk.test:3000/api/v4/projects/19/packages/npm/@packages/sample/-/@packages/sample-1.0.0.tgz"},
     "name"=>"@packages/sample",
     "version"=>"1.0.0"}},
 "dist-tags"=>{"latest"=>"6.0.0"}}

However, when comparing the deprecated message the service will take the value from the first version source. In our example it'll be Deprecated and the requested version won't be un-deprecated, since it already has deprecated: Deprecated in the metadatum.

Solution

Change how the service handles the deprecation message: it should depend on the currently proceed package's version.

Edited by 🤖 GitLab Bot 🤖