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

Assets on a draft release can be null #454

Closed
Talkar opened this issue Jun 9, 2022 · 4 comments · Fixed by #484
Closed

Assets on a draft release can be null #454

Talkar opened this issue Jun 9, 2022 · 4 comments · Fixed by #484
Labels
Milestone

Comments

@Talkar
Copy link

Talkar commented Jun 9, 2022

Hi
It seems that when creating a new release with assets, the draft release will have a null entry for its assets.
I'm getting a NullReferenceException on this line

var existingAsset = release.Assets.FirstOrDefault(a => a.Name == assetFileName);

image

@Windos
Copy link

Windos commented Sep 7, 2022

I'm also seeing this when trying to pass in an asset while creating a draft release. Adding the same asset to an existing draft release works.

grm create --milestone '0.1.0' --token $env:GitHubPAT --owner Windos --repository example --assets '.\Output\Manifest.0.1.0.json'
[FTL] Object reference not set to an instance of an object.
System.NullReferenceException: Object reference not set to an instance of an object.
   at GitReleaseManager.Core.VcsService.<AddAssetsAsync>d__13.MoveNext() in /_/src/GitReleaseManager.Core/VcsService.cs:line 147
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at GitReleaseManager.Core.VcsService.<CreateReleaseAsync>d__11.MoveNext() in /_/src/GitReleaseManager.Core/VcsService.cs:line 106
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at GitReleaseManager.Core.VcsService.<CreateReleaseFromMilestoneAsync>d__9.MoveNext() in /_/src/GitReleaseManager.Core/VcsService.cs:line 56
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at GitReleaseManager.Core.Commands.CreateCommand.<Execute>d__3.MoveNext() in /_/src/GitReleaseManager.Core/Commands/CreateCommand.cs:line 41
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at GitReleaseManager.Cli.Program.<Main>d__1.MoveNext() in /_/src/GitReleaseManager.Cli/Program.cs:line 34

jibedoubleve added a commit to jibedoubleve/GitReleaseManager that referenced this issue Jan 2, 2023
jibedoubleve added a commit to jibedoubleve/GitReleaseManager that referenced this issue Jan 2, 2023
@jibedoubleve
Copy link
Contributor

jibedoubleve commented Jan 2, 2023

How to reproduce it

I can reproduce the issue when I execute the command below

grm create --milestone 2.0.1 --token [HIDDEN] --owner OWNER --repository [REPOSITORY] --assets "D:/Projects/project/Publish/xxx.2.0.1-beta.64.bin.zip", "D:/Projects/project/Publish/xxx.2.0.1-beta.64.setup.exe"

What is happening?

The problem is that when I'm getting the release, I'm trying to find a released tagged 2.0.1. Because there's no release (sic.) with tag 2.0.1, NULL is returned

var release = await _vcsProvider.GetReleaseAsync(owner, repository, tagName).ConfigureAwait(false);

Later, I'm trying to query the assets on a NULL collection of releases => NullReferenceException

var existingAsset = release.Assets.FirstOrDefault(a => a.Name == assetFileName);

Why is it happening?

When creating a release with assets, it first creates the release, and then it uploads the assets. To upload the assets, we need the release, therefore we retrieve the created release.

It seems that when we try to retrieve the freshly created release, it's not yet available and this is the root cause of the NullReferenceException

How to fix it?

Instead of retrieving the release from the wire, we can provide the created release to the method that is in charge of uploading the assets

gep13 pushed a commit to jibedoubleve/GitReleaseManager that referenced this issue Aug 21, 2023
gep13 pushed a commit to jibedoubleve/GitReleaseManager that referenced this issue Aug 21, 2023
@gep13 gep13 linked a pull request Aug 21, 2023 that will close this issue
@gep13 gep13 added this to the 0.14.0 milestone Aug 21, 2023
@gep13 gep13 added the Bug label Aug 21, 2023
@gep13
Copy link
Member

gep13 commented Aug 21, 2023

Huge thanks to @jibedoubleve who was able to figure out the solution to this problem, and provide a PR to get it working.

The issue will be addressed in the 0.14.0 release of GitReleaseManager.

@gep13 gep13 closed this as completed Aug 21, 2023
gep13 added a commit that referenced this issue Aug 22, 2023
* release/0.14.0: (28 commits)
  (maint) Consolidate and remove duplicates
  (maint) Update PackageReference
  (maint) Update PackageReference
  Bump Serilog.Sinks.Console from 4.0.1 to 4.1.0 in /src
  Bump Shouldly from 4.0.3 to 4.2.1 in /src
  Bump Microsoft.Extensions.DependencyInjection in /src
  Bump TextCopy from 6.1.0 to 6.2.1 in /src
  Bump Microsoft.CodeAnalysis.NetAnalyzers from 6.0.0 to 7.0.3 in /src
  Bump NSubstitute from 4.3.0 to 5.0.0 in /src
  Bump Microsoft.NET.Test.Sdk from 17.0.0 to 17.7.1 in /src
  Bump Scriban from 5.0.0 to 5.7.0 in /src
  Bump IDisposableAnalyzers from 4.0.1 to 4.0.6 in /src
  Bump NUnit from 3.13.2 to 3.13.3 in /src
  Bump CommandLineParser from 2.8.0 to 2.9.1 in /src
  Bump coverlet.msbuild from 3.1.1 to 6.0.0 in /src
  Bump Roslynator.Analyzers from 4.0.2 to 4.4.0 in /src
  Bump ApprovalTests from 5.7.1 to 5.8.0 in /src
  (#454) Create test
  (#454) Fix NullReferenceException on release not found
  (build) Force building of 0.14.0
  ...
@gittools-bot
Copy link
Contributor

🎉 This issue has been resolved in version 0.14.0 🎉

The release is available on:

Your GitReleaseManager bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants