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

Regression - 3.4.190 fails to parse version.json file #580

Closed
olegoid opened this issue Apr 7, 2021 · 3 comments · Fixed by #581
Closed

Regression - 3.4.190 fails to parse version.json file #580

olegoid opened this issue Apr 7, 2021 · 3 comments · Fixed by #581
Labels
Milestone

Comments

@olegoid
Copy link

olegoid commented Apr 7, 2021

This issue can be reproduced with Cascade repo by running nbgv cloud

Unhandled exception: System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> Newtonsoft.Json.JsonReaderException: Additional text encountered after finished reading JSON content: 8. Path '', line 30, position 1.
   at Newtonsoft.Json.JsonTextReader.Read()
   at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.Deserialize(JsonReader reader, Type objectType, Boolean checkAdditionalContent)
   at Newtonsoft.Json.JsonSerializer.DeserializeInternal(JsonReader reader, Type objectType)
   at Newtonsoft.Json.JsonConvert.DeserializeObject(String value, Type type, JsonSerializerSettings settings)
   at Newtonsoft.Json.JsonConvert.DeserializeObject[T](String value, JsonSerializerSettings settings)
   at Nerdbank.GitVersioning.VersionFile.TryReadVersionJsonContent(String jsonContent, String repoRelativeBaseDirectory) in D:\a\1\s\src\NerdBank.GitVersioning\VersionFile.cs:line 142
   at Nerdbank.GitVersioning.Managed.ManagedVersionFile.GetVersion(GitCommit commit, String repoRelativeProjectDirectory, Dictionary`2 blobVersionCache, String& actualDirectory) in D:\a\1\s\src\NerdBank.GitVersioning\Managed\ManagedVersionFile.cs:line 105
   at Nerdbank.GitVersioning.Managed.ManagedVersionFile.GetVersionCore(String& actualDirectory) in D:\a\1\s\src\NerdBank.GitVersioning\Managed\ManagedVersionFile.cs:line 41
   at Nerdbank.GitVersioning.VersionOracle..ctor(GitContext context, ICloudBuild cloudBuild, Nullable`1 overrideVersionHeightOffset) in D:\a\1\s\src\NerdBank.GitVersioning\VersionOracle.cs:line 39
   at Nerdbank.GitVersioning.Tool.Program.OnCloudCommand(String project, IReadOnlyList`1 metadata, String version, String ciSystem, Boolean allVars, Boolean commonVars, IReadOnlyList`1 define) in D:\a\1\s\src\nbgv\Program.cs:line 601
   --- End of inner exception stack trace ---
   at System.RuntimeMethodHandle.InvokeMethod(Object target, Object[] arguments, Signature sig, Boolean constructor, Boolean wrapExceptions)
   at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
   at System.Delegate.DynamicInvokeImpl(Object[] args)
   at System.CommandLine.Invocation.ModelBindingCommandHandler.InvokeAsync(InvocationContext context)
   at System.CommandLine.Invocation.InvocationPipeline.<>c__DisplayClass4_0.<<BuildInvocationChain>b__0>d.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.CommandLine.Builder.CommandLineBuilderExtensions.<>c.<<UseParseErrorReporting>b__21_0>d.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.CommandLine.Builder.CommandLineBuilderExtensions.<>c__DisplayClass16_0.<<UseHelp>b__0>d.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.CommandLine.Builder.CommandLineBuilderExtensions.<>c__DisplayClass25_0.<<UseVersionOption>b__0>d.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.CommandLine.Builder.CommandLineBuilderExtensions.<>c__DisplayClass23_0.<<UseTypoCorrections>b__0>d.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.CommandLine.Builder.CommandLineBuilderExtensions.<>c.<<UseSuggestDirective>b__22_0>d.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.CommandLine.Builder.CommandLineBuilderExtensions.<>c.<<UseParseDirective>b__20_0>d.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.CommandLine.Builder.CommandLineBuilderExtensions.<>c.<<UseDebugDirective>b__11_0>d.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.CommandLine.Builder.CommandLineBuilderExtensions.<>c.<<RegisterWithDotnetSuggest>b__10_0>d.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.CommandLine.Builder.CommandLineBuilderExtensions.<>c__DisplayClass19_0.<<UseMiddleware>b__0>d.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.CommandLine.Builder.CommandLineBuilderExtensions.<>c__DisplayClass14_0.<<UseExceptionHandler>b__0>d.MoveNext()

nbgv v3.2.31 works fine on the same revision.

@AArnott
Copy link
Collaborator

AArnott commented Apr 7, 2021

I see v3.3.37 also worked fine. I can repro the problem on v3.4. I'm investigating.

@olegoid
Copy link
Author

olegoid commented Apr 7, 2021

Thanks, @AArnott!

@AArnott
Copy link
Collaborator

AArnott commented Apr 7, 2021

This is a regression in our reading of git objects. You can workaround it either by pinning the older version of NB.GV, or by setting the env var to use libgit2 as described in these release notes.

@qmfrederik: this fails on the very first commit encountered, in that it produces the content of the version.json file from the HEAD commit for parsing, but then that content has several lines of trailing text that looks like it came from the middle of that same file. The result is the JSON object is followed by an invalid JSON fragment.
I wonder if there's a bug in the managed git file delta-processing where we incorrectly reconstruct the plaintext. Any ideas?

@AArnott AArnott added the bug label Apr 7, 2021
@AArnott AArnott added this to the v3.4 milestone Apr 7, 2021
AArnott added a commit that referenced this issue Apr 7, 2021
In the case of this bug, the `Stream.Read` method read fewer bytes than was requested. This is totally allowed, but the caller did not expect it and assumed the entire buffer was initialized rather than a subset of it.

Fixes #580
@AArnott AArnott closed this as completed Apr 7, 2021
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.

2 participants