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

The JSON value could not be converted to System.Int32 #633

Closed
gep13 opened this issue Jan 9, 2025 · 1 comment · Fixed by #634
Closed

The JSON value could not be converted to System.Int32 #633

gep13 opened this issue Jan 9, 2025 · 1 comment · Fixed by #634
Assignees
Milestone

Comments

@gep13
Copy link
Member

gep13 commented Jan 9, 2025

Description

When running some GitReleaseManager commands using the GitLab provider, a fatal error is thrown, and the command does not complete successfully.

Error that is thrown is:

The JSON value could not be converted to System.Int32. Path: $.id | LineNumber: 0 | BytePositionInLine: 16.

Expected Behavior

Running any command in GitReleaseManager, when using the GitLab provider, should complete successfully.

Actual Behavior

A fatal error is being thrown, and the command is not completing successfully.

Possible Fix

Update to the latest NGitLab package version.

Steps to Reproduce

Make sure that you have a milestone configured, with some issues assigned to it with correct labels, etc, and then run:

create -m v0.1.2 -n v0.1.2 -c master -o gep13 -r fakeproject --token <token> --provider GitLab

This should work, without any problems. Then run:

publish -t v0.1.2 -o gep13 -r fakeproject --token <token> --provider GitLab

Which should also run without any problems.

Make sure that you have a GitReleaseManager.yaml file in place, which enables the use-issue-comments: true configuration, and then run:

close -m v0.1.2 -o gep13 -r fakeproject --token <token> --provider GitLab

This should fail with the following error:

[FTL] The JSON value could not be converted to System.Int32. Path: $.id | LineNumber: 0 | BytePositionInLine: 16.
GitReleaseManager.Core.Exceptions.ApiException: The JSON value could not be converted to System.Int32. Path: $.id | LineNumber: 0 | BytePositionInLine: 16.
 ---> System.Text.Json.JsonException: The JSON value could not be converted to System.Int32. Path: $.id | LineNumber: 0 | BytePositionInLine: 16.
 ---> System.FormatException: Either the JSON value is not in a supported format, or is out of bounds for an Int32.
   at System.Text.Json.ThrowHelper.ThrowFormatException(NumericType numericType)
   at NGitLab.Impl.Json.Int32Converter.Read(Utf8JsonReader& reader, Type type, JsonSerializerOptions options) in /_/NGitLab/Impl/Json/Int32Converter.cs:line 33
   at System.Text.Json.Serialization.JsonConverter`1.TryRead(Utf8JsonReader& reader, Type typeToConvert, JsonSerializerOptions options, ReadStack& state, T& value, Boolean& isPopulatedValue)
   at System.Text.Json.Serialization.Metadata.JsonPropertyInfo`1.ReadJsonAndSetMember(Object obj, ReadStack& state, Utf8JsonReader& reader)
   at System.Text.Json.Serialization.Converters.ObjectDefaultConverter`1.OnTryRead(Utf8JsonReader& reader, Type typeToConvert, JsonSerializerOptions options, ReadStack& state, T& value)
   at System.Text.Json.Serialization.JsonConverter`1.TryRead(Utf8JsonReader& reader, Type typeToConvert, JsonSerializerOptions options, ReadStack& state, T& value, Boolean& isPopulatedValue)
   at System.Text.Json.Serialization.JsonConverter`1.ReadCore(Utf8JsonReader& reader, JsonSerializerOptions options, ReadStack& state)
   --- End of inner exception stack trace ---
   at System.Text.Json.ThrowHelper.ReThrowWithPath(ReadStack& state, Utf8JsonReader& reader, Exception ex)
   at System.Text.Json.Serialization.JsonConverter`1.ReadCore(Utf8JsonReader& reader, JsonSerializerOptions options, ReadStack& state)
   at System.Text.Json.JsonSerializer.ReadFromSpan[TValue](ReadOnlySpan`1 utf8Json, JsonTypeInfo`1 jsonTypeInfo, Nullable`1 actualByteCount)
   at System.Text.Json.JsonSerializer.ReadFromSpan[TValue](ReadOnlySpan`1 json, JsonTypeInfo`1 jsonTypeInfo)
   at System.Text.Json.JsonSerializer.Deserialize[TValue](String json, JsonSerializerOptions options)
   at NGitLab.Impl.Json.Serializer.Deserialize[T](String json) in /_/NGitLab/Impl/Json/Serializer.cs:line 29
   at NGitLab.Impl.HttpRequestor.<>c__DisplayClass11_0`1.<To>b__0(Stream s) in /_/NGitLab/Impl/HttpRequestor.cs:line 67
   at NGitLab.Impl.HttpRequestor.StreamAndHeaders(String tailAPIUrl, Action`2 parser) in /_/NGitLab/Impl/HttpRequestor.cs:line 148
   at NGitLab.Impl.HttpRequestor.To[T](String tailAPIUrl) in /_/NGitLab/Impl/HttpRequestor.cs:line 65
   at GitReleaseManager.Core.Provider.GitLabProvider.<>c__DisplayClass14_0.<CreateIssueCommentAsync>b__0() in C:\code\GitReleaseManager\src\GitReleaseManager.Core\Provider\GitLabProvider.cs:line 111
   at GitReleaseManager.Core.Provider.GitLabProvider.ExecuteAsync(Func`1 action) in C:\code\GitReleaseManager\src\GitReleaseManager.Core\Provider\GitLabProvider.cs:line 412
   --- End of inner exception stack trace ---
   at GitReleaseManager.Core.Provider.GitLabProvider.ExecuteAsync(Func`1 action) in C:\code\GitReleaseManager\src\GitReleaseManager.Core\Provider\GitLabProvider.cs:line 420
   at GitReleaseManager.Core.VcsService.AddIssueCommentsAsync(String owner, String repository, Milestone milestone) in C:\code\GitReleaseManager\src\GitReleaseManager.Core\VcsService.cs:line 399
   at GitReleaseManager.Core.VcsService.CloseMilestoneAsync(String owner, String repository, String milestoneTitle) in C:\code\GitReleaseManager\src\GitReleaseManager.Core\VcsService.cs:line 262
   at GitReleaseManager.Core.Commands.CloseCommand.ExecuteAsync(CloseSubOptions options) in C:\code\GitReleaseManager\src\GitReleaseManager.Core\Commands\CloseCommand.cs:line 21
   at GitReleaseManager.Cli.Program.Main(String[] args) in C:\code\GitReleaseManager\src\GitReleaseManager.Cli\Program.cs:line 36

Context

This is related to an upstream issue with the NGitLab library which is being used. It is similar to another issue which was affecting GitHub. Basically, the type of some of the properties on the API Models are set to be an int32, and now the ids of the issues/PRs/Comments, etc, are now bigger than the maximum integer allowed in that type, and as a result, they fail when the serialization of the model is attempted.

This should be fixed in version 7.0.0 of NGitLab, so we will need to update to that package version, and make any required follow up changes.

Your Environment

I have a FakeProject in GitLab, which is used to test these things out, which can be found here:

https://gitlab.com/gep13/fakeproject

  • Version Used: Latest code from develop branch
  • Edition Used (.NET Core, .NET Framework): N/A
  • Operating System and version (Windows 10, Ubuntu 18.04): N/A
  • Link to your project: N/A
  • Link to your CI build (if appropriate): N/A
@gep13 gep13 self-assigned this Jan 9, 2025
gep13 added a commit to gep13/GitReleaseManager that referenced this issue Jan 9, 2025
This addresses an issue which was seen when trying to close milestones
using the GitLab provider. There would be an error thrown regarding
being able to correctly serialize a number into an int32, since the
number was too big.

An upstream change was needed in NGitLab, so switch to usign to a long.
There was a similar error when using GitHub, and a bump in the version
of Octokit being used was required.

This has been tested against a GitLab repository, and the close command
which was previously failing is now working.
@gep13 gep13 added this to the 0.19.0 milestone Jan 9, 2025
gep13 added a commit to gep13/GitReleaseManager that referenced this issue Jan 9, 2025
This addresses an issue which was seen when trying to close milestones
using the GitLab provider. There would be an error thrown regarding
being able to correctly serialize a number into an int32, since the
number was too big.

An upstream change was needed in NGitLab, so switch to usign to a long.
There was a similar error when using GitHub, and a bump in the version
of Octokit being used was required.

This has been tested against a GitLab repository, and the close command
which was previously failing is now working.
AdmiringWorm added a commit that referenced this issue Jan 9, 2025
(#633) Update to latest NGitLab package version
@gittools-bot
Copy link
Contributor

🎉 This issue has been resolved in version 0.19.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
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants