NuGet package upload doesn't work with 'curl'
Summary
On our doc: NuGet API: Upload a package file, it mentions the following command to upload a NuGet package:
curl --request PUT \
--upload-file path/to/mynugetpkg.1.3.0.17.nupkg \
--user <username>:<personal_access_token> \
"https://gitlab.example.com/api/v4/projects/1/packages/nuget"
But, this does not work. nuget push
works though.
Steps to reproduce
- Create a project in an SM instance or GitLab.com.
- Try to push a sample NuGet package using the above example command.
Push results in 500, Whoops, something went wrong on our end.
error.
Example Project
Any GitLab.com project.
What is the current bug behavior?
Push with curl
doesn't work.
What is the expected correct behavior?
Push should work with curl
.
Relevant logs and/or screenshots
Found the below error in production.log
:
Started PUT "/api/v4/projects/58/packages/nuget" for 34.90.190.155 at 2021-09-14 05:22:58 +0000
NoMethodError (undefined method `reverse_merge' for nil:NilClass):
lib/api/api.rb:107:in `block in <class:API>'
lib/gitlab/metrics/elasticsearch_rack_middleware.rb:16:in `call'
lib/gitlab/middleware/rails_queue_duration.rb:33:in `call'
lib/gitlab/metrics/rack_middleware.rb:16:in `block in call'
lib/gitlab/metrics/web_transaction.rb:21:in `run'
lib/gitlab/metrics/rack_middleware.rb:16:in `call'
lib/gitlab/middleware/speedscope.rb:13:in `call'
lib/gitlab/request_profiler/middleware.rb:17:in `call'
lib/gitlab/jira/middleware.rb:19:in `call'
lib/gitlab/middleware/go.rb:20:in `call'
lib/gitlab/etag_caching/middleware.rb:21:in `call'
lib/gitlab/middleware/multipart.rb:172:in `call'
lib/gitlab/middleware/read_only/controller.rb:50:in `call'
lib/gitlab/middleware/read_only.rb:18:in `call'
lib/gitlab/middleware/same_site_cookies.rb:27:in `call'
lib/gitlab/middleware/handle_malformed_strings.rb:21:in `call'
lib/gitlab/middleware/basic_health_check.rb:25:in `call'
lib/gitlab/middleware/handle_ip_spoof_attack_error.rb:25:in `call'
lib/gitlab/middleware/request_context.rb:21:in `call'
config/initializers/fix_local_cache_middleware.rb:11:in `call'
lib/gitlab/middleware/rack_multipart_tempfile_factory.rb:19:in `call'
lib/gitlab/metrics/requests_rack_middleware.rb:74:in `call'
lib/gitlab/middleware/release_env.rb:12:in `call'
strace
on Puma shows the below:
30203 04:54:12.213753 read(48</opt/gitlab/embedded/lib/ruby/gems/2.7.0/gems/grape-1.5.2/lib/grape/parser/xml.rb>, "# frozen_string_literal: true\n\nmodule Grape\n module Parser\n module Xml\n class << self\n def call(object, _env)\n ::Grape::Xml.parse(object)\n rescue ::Grape::Xml::ParseError\n # handle XML parsing errors via the rescue handlers or provide error message\n raise Grape::Exceptions::InvalidMessageBody, 'application/xml'\n end\n end\n end\n end\nend\n", 8192) = 403 <0.000023>
30203 04:54:12.213929 read(48</opt/gitlab/embedded/lib/ruby/gems/2.7.0/gems/grape-1.5.2/lib/grape/parser/xml.rb>, "", 8192) = 0 <0.000024>
Could find that Grape tried to parse the request with both json and xml before it failed.
Specifying headers Content-Type: multipart/form-data
and Content-Encoding: gzip
on the curl command resulted in Bad request
error.
Output of checks
Happens on GitLab.com and SM.
Results of GitLab environment info
Expand for output related to GitLab environment info
(For installations with omnibus-gitlab package run and paste the output of: `sudo gitlab-rake gitlab:env:info`) (For installations from source run and paste the output of: `sudo -u git -H bundle exec rake gitlab:env:info RAILS_ENV=production`)
Results of GitLab application Check
Expand for output related to the GitLab application check
(For installations with omnibus-gitlab package run and paste the output of:
sudo gitlab-rake gitlab:check SANITIZE=true
)(For installations from source run and paste the output of:
sudo -u git -H bundle exec rake gitlab:check RAILS_ENV=production SANITIZE=true
)(we will only investigate if the tests are passing)