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

Json parser problem with handling null values #3

Closed
pazunino opened this issue May 5, 2020 · 4 comments
Closed

Json parser problem with handling null values #3

pazunino opened this issue May 5, 2020 · 4 comments

Comments

@pazunino
Copy link

pazunino commented May 5, 2020

Hi, in 3.0.0 when Releases have null Status or Recordings have null Length the Find and Look methods quits throwing a Json error.
Follow a stacktrace copy of a Recording with null length.
System.Text.Json.JsonException: Failed to deserialize the 'media' property.
---> System.Text.Json.JsonException: Failed to deserialize the 'tracks' property.
---> System.Text.Json.JsonException: Failed to deserialize the 'recording' property.
---> System.Text.Json.JsonException: Failed to deserialize the 'length' property.
---> System.InvalidOperationException: Cannot get the value of a token type 'Null' as a number.
at at System.Text.Json.Utf8JsonReader.TryGetDouble(Double& value)
at at System.Text.Json.Utf8JsonReader.GetDouble()
at at MetaBrainz.MusicBrainz.Json.Readers.RecordingReader.ReadObjectContents(Utf8JsonReader& reader, JsonSerializerOptions options)
--- End of inner exception stack trace ---
at at MetaBrainz.MusicBrainz.Json.Readers.RecordingReader.ReadObjectContents(Utf8JsonReader& reader, JsonSerializerOptions options)
at at MetaBrainz.Common.Json.Converters.ObjectReader1.Read(Utf8JsonReader& reader, Type typeToConvert, JsonSerializerOptions options) at at MetaBrainz.Common.Json.JsonUtils.GetObject[T](Utf8JsonReader& reader, JsonConverter1 converter, JsonSerializerOptions options)
at at MetaBrainz.Common.Json.JsonUtils.GetOptionalObject[T](Utf8JsonReader& reader, JsonConverter1 converter, JsonSerializerOptions options) at at MetaBrainz.MusicBrainz.Json.Readers.TrackReader.ReadObjectContents(Utf8JsonReader& reader, JsonSerializerOptions options) --- End of inner exception stack trace --- at at MetaBrainz.MusicBrainz.Json.Readers.TrackReader.ReadObjectContents(Utf8JsonReader& reader, JsonSerializerOptions options) at at MetaBrainz.Common.Json.Converters.ObjectReader1.Read(Utf8JsonReader& reader, Type typeToConvert, JsonSerializerOptions options)
at at MetaBrainz.Common.Json.JsonUtils.ReadList[T,TValue](Utf8JsonReader& reader, JsonConverter1 converter, JsonSerializerOptions options) at at MetaBrainz.Common.Json.JsonUtils.ReadList[T](Utf8JsonReader& reader, JsonConverter1 converter, JsonSerializerOptions options)
at at MetaBrainz.MusicBrainz.Json.Readers.MediumReader.ReadObjectContents(Utf8JsonReader& reader, JsonSerializerOptions options)
--- End of inner exception stack trace ---
at at MetaBrainz.MusicBrainz.Json.Readers.MediumReader.ReadObjectContents(Utf8JsonReader& reader, JsonSerializerOptions options)
at at MetaBrainz.Common.Json.Converters.ObjectReader1.Read(Utf8JsonReader& reader, Type typeToConvert, JsonSerializerOptions options) at at MetaBrainz.Common.Json.JsonUtils.ReadList[T,TValue](Utf8JsonReader& reader, JsonConverter1 converter, JsonSerializerOptions options)
at at MetaBrainz.Common.Json.JsonUtils.ReadList[T](Utf8JsonReader& reader, JsonConverter1 converter, JsonSerializerOptions options) at at MetaBrainz.MusicBrainz.Json.Readers.ReleaseReader.ReadObjectContents(Utf8JsonReader& reader, JsonSerializerOptions options) --- End of inner exception stack trace --- at at MetaBrainz.MusicBrainz.Json.Readers.ReleaseReader.ReadObjectContents(Utf8JsonReader& reader, JsonSerializerOptions options) at at MetaBrainz.Common.Json.Converters.ObjectReader1.Read(Utf8JsonReader& reader, Type typeToConvert, JsonSerializerOptions options)
at at System.Text.Json.JsonPropertyInfoNotNullable`4.OnRead(ReadStack& state, Utf8JsonReader& reader)
at at System.Text.Json.JsonPropertyInfo.Read(JsonTokenType tokenType, ReadStack& state, Utf8JsonReader& reader)
at at System.Text.Json.JsonSerializer.ReadCore(JsonSerializerOptions options, Utf8JsonReader& reader, ReadStack& readStack)
at at System.Text.Json.JsonSerializer.ReadCore(Type returnType, JsonSerializerOptions options, Utf8JsonReader& reader)
at at System.Text.Json.JsonSerializer.Deserialize(String json, Type returnType, JsonSerializerOptions options)
at at System.Text.Json.JsonSerializer.Deserialize[TValue](String json, JsonSerializerOptions options)
at at MetaBrainz.Common.Json.JsonUtils.Deserialize[T](String json, JsonSerializerOptions options)
at at MetaBrainz.MusicBrainz.Query.Deserialize[T](String json)
at at MetaBrainz.MusicBrainz.Query.LookupReleaseAsync(Guid mbid, Include inc)

@Zastai
Copy link
Owner

Zastai commented May 5, 2020

Thanks for the report. I'll have a look.

@Zastai
Copy link
Owner

Zastai commented May 5, 2020

Note: when reporting things like this, it's always useful to include the MBID (or search terms, for FindXXX) you were using.

@Zastai Zastai closed this as completed in 252161a May 5, 2020
@pazunino
Copy link
Author

pazunino commented May 5, 2020 via email

@Zastai
Copy link
Owner

Zastai commented May 5, 2020

Now when a track or recording has no length, its Length property will simply be null.

For a track it just means that information was not added when the release was added (and shown as ?:?? on the MusicBrainz website).
For a recording it means that none of the tracks on which it appears have a length set (normally it's an average of all those lengths).

So if that data is needed, it will indeed need to be added to MusicBrainz via the website.

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

No branches or pull requests

2 participants