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

Unstable - Error deserializing item with JSON #4172

Closed
blablup opened this issue Sep 17, 2020 · 8 comments
Closed

Unstable - Error deserializing item with JSON #4172

blablup opened this issue Sep 17, 2020 · 8 comments
Labels
bug Something isn't working

Comments

@blablup
Copy link

blablup commented Sep 17, 2020

Hello,

I still get the Error, I thought it should be fixed by #MR3951 (#3951). Maybe commit 9ddf550 broke it again?

Sep 17 13:58:05 media jellyfin[21454]: [13:58:05] [DBG] AuthenticationScheme: CustomAuthentication was successfully authenticated.
Sep 17 13:58:05 media jellyfin[21454]: [13:58:05] [ERR] Error deserializing item with JSON: {"SpecialFeatureIds":[],"LocalTrailerIds":[],"RemoteTrailerIds":[],"TmdbCollectionName":null,"AdditionalParts":[],"LocalAlternateVersions":[],"LinkedAlternateVersions":[],"Timestamp":null,"SubtitleFiles":[],"HasSubtitles":false,"IsPlaceHolder":false,"DefaultVideoStreamIndex":0,"VideoType":"VideoFile","IsoType":null,"Video3DFormat":null,"AspectRatio":null,"Size":"2083739494","Container":"mov,mp4,m4a,3gp,3g2,mj2","DateLastSaved":"2020-08-11T17:50:35.1846658Z","RemoteTrailers":[{"Url":"https://www.youtube.com/watch?v=sPXByAnJWNc","Name":"Die Stunde des Verbrechens - Trailer"}],"IsHD":true,"IsShortcut":false,"ShortcutPath":null,"Width":1280,"Height":720,"ExtraIds":[],"SupportsExternalTransfer":false}
Sep 17 13:58:05 media jellyfin[21454]: System.Text.Json.JsonException: The JSON value could not be converted to System.Nullable`1[System.Int64]. Path: $.Size | LineNumber: 0 | BytePositionInLine: 376.

I get this Error if I try to modify Metadata. Also depending on which fields are filled I get Error responses from server like:
{"type":"https://tools.ietf.org/html/rfc7231#section-6.5.1","title":"One or more validation errors occurred.","status":400,"traceId":"|7cead06d-45afd8ac33c5f67a.","errors":{"request":["The request field is required."],"$.ProductionYear":["The JSON value could not be converted to System.Nullable`1[System.Int32]. Path: $.ProductionYear | LineNumber: 0 | BytePositionInLine: 562."]}}

System (please complete the following information):

  • OS: Debian 10.5
  • Virtualization: LXC
  • Clients: Browser
  • Browser: Firefox 80
  • Jellyfin Version: 20200913.1-unstable or build from source
  • Reverse Proxy: nginx
  • Base URL: none

To Reproduce

  1. Go to 'Metadata Manager'
  2. Click on 'any Movie'
  3. Change a value and save
  4. See error
@blablup blablup added the bug Something isn't working label Sep 17, 2020
@BaronGreenback
Copy link
Contributor

Getting a similar JSON error trying to edit dlna profiles.

image

image

Exception:-

System.InvalidOperationException
  HResult=0x80131509
  Message=Cannot get the value of a token type 'String' as a number.
  Source=System.Text.Json
  StackTrace:
   at System.Text.Json.Utf8JsonReader.TryGetInt64(Int64& value)
   at System.Text.Json.Utf8JsonReader.GetInt64()
   at System.Text.Json.Serialization.Converters.Int64Converter.Read(Utf8JsonReader& reader, Type typeToConvert, JsonSerializerOptions options)
   at System.Text.Json.Serialization.Converters.NullableConverter`1.Read(Utf8JsonReader& reader, Type typeToConvert, JsonSerializerOptions options)
   at MediaBrowser.Common.Json.Converters.JsonNullableStructConverter`1.Read(Utf8JsonReader& reader, Type typeToConvert, JsonSerializerOptions options) in C:\code\jellyfin\MediaBrowser.Common\Json\Converters\JsonNullableStructConverter.cs:line 35
   at System.Text.Json.Serialization.JsonConverter`1.TryRead(Utf8JsonReader& reader, Type typeToConvert, JsonSerializerOptions options, ReadStack& state, T& value)
   at System.Text.Json.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)
   at System.Text.Json.Serialization.JsonConverter`1.ReadCore(Utf8JsonReader& reader, JsonSerializerOptions options, ReadStack& state)

@BaronGreenback
Copy link
Contributor

dotnet/runtime#30255

@BaronGreenback
Copy link
Contributor

dotnet/runtime#42239

Custom handlers and number convertors are mutually exclusive.

@BaronGreenback
Copy link
Contributor

Fix #4180

@layomia
Copy link

layomia commented Sep 18, 2020

Custom handlers and number convertors are mutually exclusive.

What do you mean by this?

The issue here appears to be that a custom converter for a number type is not doing a check for whether the number payload is written as a number or a string. I left a comment in #4180 that suggests the recommended way to do this.

Unless the JsonNumberHandling feature new in .NET 5 is being used here, I don't believe that the issue has any thing to do with dotnet/runtime#42239.

@BaronGreenback
Copy link
Contributor

dotnet/runtime/#42239 was referenced as it states in the code the shows the comment "'JsonNumberHandlingAttribute' cannot be placed on a property, field, or type that is handled by a custom converter".

The JsonNumberHandling feature is being used in jsOnDefaults.cs

@layomia
Copy link

layomia commented Sep 20, 2020

"'JsonNumberHandlingAttribute' cannot be placed on a property, field, or type that is handled by a custom converter".

Was this exception thrown when running your own code? I can't see anything that indicates that.

I've looked at the settings in JsonDefaults.cs, and the number handling setting is specified globally on JsonSerializerOptions. The above exception is only thrown when JsonNumberHandlingAttribute is placed on a property or type which also has a custom converter.

@crobibero
Copy link
Member

This is fixed in master.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

4 participants