NuGet / Home

Repo for NuGet Client issues
Other
1.5k stars 253 forks source link

Missing resilience? #13540

Closed bstordrup closed 2 months ago

bstordrup commented 3 months ago

NuGet Product Used

NuGet.exe

Product Version

nuget 6.11.0.64

Worked before?

No response

Impact

It's more difficult to complete my work

Repro Steps & Context

Sometimes, I get this error when running nuget push:

Error getting pkg from body: unable to open nuspec file from nupkg archive: zip: not a valid zip file

Then I can issue the exact same nuget push command again, and it succeeds without the error, and the package is pushed.

It most often happen if the commands get executed too soon after each other - for example in a PowerShell script that pushes a series of nupkg's.

I suspect that there is some kind of resilience issue involved.

Verbose Logs

Output from two subsequent runs:

PS C:\LocalStorage\Visma.Services.UserDirectory.Diagnostics> nuget push Visma.Services.UserDirectory.Diagnostics.18.0.0.4.nupkg -source https://nuget.pkg.github.com/MyGitOrganization/index.json -ApiKey ********************************
Pushing Visma.Services.UserDirectory.Diagnostics.18.0.0.4.nupkg to 'https://nuget.pkg.github.com/MyGitOrganization'...
  PUT https://nuget.pkg.github.com/MyGitOrganization/
WARNING: Error getting pkg from body: unable to open nuspec file from nupkg archive: zip: not a valid zip file
  BadRequest https://nuget.pkg.github.com/MyGitOrganization/ 384ms
Response status code does not indicate success: 400 (Bad Request).
PS C:\LocalStorage\Visma.Services.UserDirectory.Diagnostics> nuget push Visma.Services.UserDirectory.Diagnostics.18.0.0.4.nupkg -source https://nuget.pkg.github.com/MyGitOrganization/index.json -ApiKey ********************************
Pushing Visma.Services.UserDirectory.Diagnostics.18.0.0.4.nupkg to 'https://nuget.pkg.github.com/MyGitOrganization'...
  PUT https://nuget.pkg.github.com/MyGitOrganization/
  OK https://nuget.pkg.github.com/MyGitOrganization/ 726ms
Your package was pushed.
bstordrup commented 3 months ago

Digging further in to this by debugging from the NuGet.Client solution, I see that the issue can be in two places:

Funny thing is that if I open the file I'm trying to push, it works fine. I can see the nuspec file just fine. And several similar packages being other versions of the same component are pushed as expected.

bstordrup commented 3 months ago

Additional info. Tried to push the package with -DisableBuffering parameter applied. There was no issue with the pulled package afterwards.

But I also did it from a Nuget.Commandline version been run from Visual Studio where I made a change to provide credentials when needed instead of providing it in Console window.

nkolev92 commented 3 months ago

Hey @bstordrup

The WARNING: part gives me a hint that this is a warning coming from the server. I think this is likely a GitHub Package Registry issue. The fact that it's an issue when there's multiple successive pushes is a further indicator as well.

Have you faced this issue with any other package registry? Have you attempted dotnet nuget push? I don't expect it to make a difference, but just covering the basis.

bstordrup commented 3 months ago

Hi @nkolev92

I did not try the dotnet nuget push.

The fact that the issue is completely gone with the -DisableBuffering parameter applied (also on calling nuget.exe from command line) makes me believe it is an issue connected to doing buffering in connection with an authenticated repository - which is the case for GitHub Packages.

But I cannot put a finger on what and where the issue is.

nkolev92 commented 3 months ago

Thanks for the quick response.

The fact that we haven't seen a lot of this, makes me think there are more likely issues server side than client side.

dotnet-policy-service[bot] commented 3 months ago

This issue has been automatically marked as stale because we have not received a response in 14 days. It will be closed if no further activity occurs within another 14 days of this comment.