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

'0x00' is an invalid start of a value. #87036

Closed
BABAYEGAR opened this issue Jun 1, 2023 · 6 comments
Closed

'0x00' is an invalid start of a value. #87036

BABAYEGAR opened this issue Jun 1, 2023 · 6 comments

Comments

@BABAYEGAR
Copy link

Description

This occurs when i try to parse very large complex json, using the JsonObject.Parse() from a file stream.

An exception is thrown as seen System.Text.Json.JsonException: '0x00' is an invalid start of a value.

I expect the json to be parsed regardless of the null trailing values

Configuration

.NET 6
Linux
x64
It works perfectly on windows but fails on Linux

Regression?

Not sure it did, a new feature i am working on uses large json so that's where i discovered the error

Other information

Exception:
System.Text.Json.JsonException: '0x00' is an invalid start of a value. Path: $ | LineNumber: 0 | BytePositionInLine: 0.
---> System.Text.Json.JsonReaderException: '0x00' is an invalid start of a value. LineNumber: 0 | BytePositionInLine: 0.
at System.Text.Json.ThrowHelper.ThrowJsonReaderException(Utf8JsonReader& json, ExceptionResource resource, Byte nextByte, ReadOnlySpan`1 bytes)
at System.Text.Json.Utf8JsonReader.ConsumeValue(Byte marker)
at System.Text.Json.Utf8JsonReader.ReadFirstToken(Byte first)
at System.Text.Json.Utf8JsonReader.ReadSingleSegment()
at System.Text.Json.Utf8JsonReader.Read()
at System.Text.Json.JsonSerializer.ReadCore(JsonSerializerOptions options, Utf8JsonReader& reader, ReadStack& readStack)
--- End of inner exception stack trace ---
at System.Text.Json.ThrowHelper.ReThrowWithPath(ReadStack& readStack, JsonReaderException ex)
at System.Text.Json.JsonSerializer.ReadCore(JsonSerializerOptions options, Utf8JsonReader& reader, ReadStack& readStack)
at System.Text.Json.JsonSerializer.ReadCore(Type returnType, JsonSerializerOptions options, Utf8JsonReader& reader)
at System.Text.Json.JsonSerializer.Deserialize(String json, Type returnType, JsonSerializerOptions options)
at System.Text.Json.JsonSerializer.Deserialize[TValue](String json, JsonSerializerOptions options)
at PowerLauncher.SettingsWatcher.OverloadSettings()
at PowerLauncher.SettingsWatcher..ctor(Settings settings)
at PowerLauncher.App.<>c__DisplayClass16_0.b__1()
at Wox.Infrastructure.Stopwatch.Normal(String message, Action action)
at PowerLauncher.App.OnStartup(Object sender, StartupEventArgs e)
at System.Windows.Application.OnStartup(StartupEventArgs e)
at System.Windows.Application.<.ctor>b__1_0(Object unused)
at System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback, Object args, Int32 numArgs)
at System.Windows.Threading.ExceptionWrapper.TryCatchWhen(Object source, Delegate callback, Object args, Int32 numArgs, Delegate catchHandler)

Seems like Newtonsoft handles such scenario correctly. But i prefer system.text.json as it is more efficient.

@BABAYEGAR
Copy link
Author

OS info: Amazon Linux 2 | x86_64, arm64

@mairaw mairaw transferred this issue from dotnet/core Jun 2, 2023
@ghost ghost added the untriaged New issue has not been triaged by the area owner label Jun 2, 2023
@ghost
Copy link

ghost commented Jun 2, 2023

Tagging subscribers to this area: @dotnet/area-system-text-json, @gregsdennis
See info in area-owners.md if you want to be subscribed.

Issue Details

Description

This occurs when i try to parse very large complex json, using the JsonObject.Parse() from a file stream.

An exception is thrown as seen System.Text.Json.JsonException: '0x00' is an invalid start of a value.

I expect the json to be parsed regardless of the null trailing values

Configuration

.NET 6
Linux
x64
It works perfectly on windows but fails on Linux

Regression?

Not sure it did, a new feature i am working on uses large json so that's where i discovered the error

Other information

Exception:
System.Text.Json.JsonException: '0x00' is an invalid start of a value. Path: $ | LineNumber: 0 | BytePositionInLine: 0.
---> System.Text.Json.JsonReaderException: '0x00' is an invalid start of a value. LineNumber: 0 | BytePositionInLine: 0.
at System.Text.Json.ThrowHelper.ThrowJsonReaderException(Utf8JsonReader& json, ExceptionResource resource, Byte nextByte, ReadOnlySpan`1 bytes)
at System.Text.Json.Utf8JsonReader.ConsumeValue(Byte marker)
at System.Text.Json.Utf8JsonReader.ReadFirstToken(Byte first)
at System.Text.Json.Utf8JsonReader.ReadSingleSegment()
at System.Text.Json.Utf8JsonReader.Read()
at System.Text.Json.JsonSerializer.ReadCore(JsonSerializerOptions options, Utf8JsonReader& reader, ReadStack& readStack)
--- End of inner exception stack trace ---
at System.Text.Json.ThrowHelper.ReThrowWithPath(ReadStack& readStack, JsonReaderException ex)
at System.Text.Json.JsonSerializer.ReadCore(JsonSerializerOptions options, Utf8JsonReader& reader, ReadStack& readStack)
at System.Text.Json.JsonSerializer.ReadCore(Type returnType, JsonSerializerOptions options, Utf8JsonReader& reader)
at System.Text.Json.JsonSerializer.Deserialize(String json, Type returnType, JsonSerializerOptions options)
at System.Text.Json.JsonSerializer.Deserialize[TValue](String json, JsonSerializerOptions options)
at PowerLauncher.SettingsWatcher.OverloadSettings()
at PowerLauncher.SettingsWatcher..ctor(Settings settings)
at PowerLauncher.App.<>c__DisplayClass16_0.b__1()
at Wox.Infrastructure.Stopwatch.Normal(String message, Action action)
at PowerLauncher.App.OnStartup(Object sender, StartupEventArgs e)
at System.Windows.Application.OnStartup(StartupEventArgs e)
at System.Windows.Application.<.ctor>b__1_0(Object unused)
at System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback, Object args, Int32 numArgs)
at System.Windows.Threading.ExceptionWrapper.TryCatchWhen(Object source, Delegate callback, Object args, Int32 numArgs, Delegate catchHandler)

Seems like Newtonsoft handles such scenario correctly. But i prefer system.text.json as it is more efficient.

Author: BABAYEGAR
Assignees: -
Labels:

area-System.Text.Json, untriaged

Milestone: -

@danmoseley
Copy link
Member

Can you share the part of the json that is causing this? Ideally reduce your json file down to just the minimum necessary to still make it fail

@eiriktsarpalis
Copy link
Member

This is by-design, but we have an issue tracking potentially tolerating invalid data:

#32291

@ghost ghost removed the untriaged New issue has not been triaged by the area owner label Jun 2, 2023
@BABAYEGAR
Copy link
Author

BABAYEGAR commented Jun 5, 2023

Hi @danmoseley Honestly its a very very large JSON for about 3MB worth of data. Its super hard to know where the error is from. The json contains excel spreadsheet data and structure but when i paste the json in a json formatter it says the json structure is valid and the error never appears on a windows machine too

@danmoseley
Copy link
Member

No problem, it looks like the team knows the issue, per above.

@ghost ghost locked as resolved and limited conversation to collaborators Jul 5, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants