loic-sharma / BaGet

A lightweight NuGet and symbol server
https://loic-sharma.github.io/BaGet/
MIT License
2.57k stars 639 forks source link

There is a 2GB limit to the size of the nugget package, so push is not possible. #797

Open woosuk-yang opened 1 month ago

woosuk-yang commented 1 month ago

Describe the bug

I am trying to push to the baget server for packages over 2GB. Packages under 2GB are uploaded, but for packages over 2GB, the error "500 (Internal Server Error)" appears.

The way I'm using the baget is in a docker. So I took an error log of the docker and confirmed that it was an error, "System.IO.InvalidDataException: Multipart body length limit 2147483647 exceeded." Can't I upload more than 2GB of packages?

Please let me know if there is a way to set the related config.

To Reproduce

Steps to reproduce the behavior:

  1. Using this version of BaGet : v0.4.0-preview2
  2. the way to use Baget : Ubuntu 20.04, docker
  3. Run this code : ../nuget.exe push -Source http://0.0.0.0:5555/v3/index.json -ApiKey -Verbosity detailed *.nupkg
  4. See error

Expected behavior

A clear and concise description of what you expected to happen.

Screenshots

Additional context

Add any other context about the problem here.

mbaksh01 commented 2 weeks ago

I've been investigating this issue and have found its cause.

At this point https://github.com/loic-sharma/BaGet/blob/5a8502ca4e3b21acd369d4a98c2529dac2d81cfe/src/BaGet/ConfigureBaGetOptions.cs#L67 the max body length is set to 2147483647 which is approximately 2.14 GB. When processing a form which is larger than this value a InvalidDataException is thrown as shown by the docs.

The ideal fix would be to accept this value from the appsettings.json file, but a temporary fix would be to increase this value to a number greater than int.MaxValue (if you have a fork of this repo).

In terms of better error handling, I think it would make sense to catch the InvalidDataException in the controller and then return a bad request indicating that the max size of NuGet packages in currently int.MaxValue;

mbaksh01 commented 2 weeks ago

Fixed in this repo https://github.com/bagetter/BaGetter/blob/7c9f535e7bd6f49b49335de07e3aaa6ee3a0ecf6/src/BaGetter/ConfigureBaGetterServer.cs#L38