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

JsonException for v2.items.manyAsync() probably because of schema version issues #143

Open
Taschenbuch opened this issue Sep 22, 2024 · 0 comments

Comments

@Taschenbuch
Copy link
Contributor

Taschenbuch commented Sep 22, 2024

Problem:
when using await gw2ApiManager.Gw2ApiClient.V2.Items.ManyAsync(itemsWithoutDetails.Select(c => c.ApiId)); // ApiId is an int in Blish sometimes gw2sharp fails to deserialize the gw2 api response. once this has happened, any further attempt to call this endpoint will result in the same exception.
It seems to be caused by using different gw2api schema versions.

If you specify that in the browser you will see that secondary_suffix_item_id is now a number: https://api.guildwars2.com/v2/items/70068?v=latest
If you do that without specifying latest it takes whatever schema before 2020-11-17T00:30:00.000Z: https://api.guildwars2.com/v2/items/70068

relevant blish hud discord discussion:
https://discord.com/channels/531175899588984842/599270434642460753/1237043452999368855
a bit later in the discussion:
https://discord.com/channels/531175899588984842/599270434642460753/1237755071161176166

start of (long) relevant discussion in gw2sharp channel in gw2 development discord:
https://discord.com/channels/384735285197537290/589031897963692034/1294737623331635230

related github issue:
gw2-api/issues#106

example exception stack trace from blish hud farming tracker module:

21:44:09.1489 | WARN  | FarmingTracker.Module | API error: get stat details from v2.items failed
FarmingTracker.Gw2ApiException: API error: get stat details from v2.items failed ---> System.Text.Json.JsonException: The JSON value could not be converted to System.Nullable`1[System.Int32]. Path: $.details.secondary_suffix_item_id | LineNumber: 0 | BytePositionInLine: 931. Path: $[18] | LineNumber: 0 | BytePositionInLine: 10883. ---> System.InvalidOperationException: Cannot get the value of a token type 'String' as a number.
   at System.Text.Json.Utf8JsonReader.TryGetInt32(Int32& value)
   at System.Text.Json.Utf8JsonReader.GetInt32()
   at System.Text.Json.Serialization.Converters.NullableConverter`1.Read(Utf8JsonReader& reader, Type typeToConvert, JsonSerializerOptions options)
   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.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)
   --- 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.Serialization.JsonConverter`1.ReadCoreAsObject(Utf8JsonReader& reader, JsonSerializerOptions options, ReadStack& state)
   at System.Text.Json.JsonSerializer.ReadCore[TValue](JsonConverter jsonConverter, Utf8JsonReader& reader, JsonSerializerOptions options, ReadStack& state)
   at System.Text.Json.JsonSerializer.ReadCore[TValue](Utf8JsonReader& reader, Type returnType, JsonSerializerOptions options)
   at System.Text.Json.JsonSerializer.Deserialize[TValue](String json, Type returnType, JsonSerializerOptions options)
   at System.Text.Json.JsonSerializer.Deserialize(String json, Type returnType, JsonSerializerOptions options)
   at Gw2Sharp.Json.Converters.CastableTypeConverter.CastableTypeConverterInner`1.Read(Utf8JsonReader& reader, Type typeToConvert, JsonSerializerOptions options)
   at System.Text.Json.Serialization.JsonConverter`1.TryRead(Utf8JsonReader& reader, Type typeToConvert, JsonSerializerOptions options, ReadStack& state, T& value)
   at System.Text.Json.Serialization.Converters.IEnumerableDefaultConverter`2.OnTryRead(Utf8JsonReader& reader, Type typeToConvert, JsonSerializerOptions options, ReadStack& state, TCollection& 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)
   at System.Text.Json.JsonSerializer.ReadCore[TValue](Utf8JsonReader& reader, Type returnType, JsonSerializerOptions options)
   at System.Text.Json.JsonSerializer.Deserialize[TValue](String json, Type returnType, JsonSerializerOptions options)
   at Gw2Sharp.WebApi.Http.WebApiRequest.<ExecuteAsync>d__10`1.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Gw2Sharp.WebApi.V2.Clients.BaseEndpointBulkClient`2.<ManyAsync>d__3.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.GetResult()
   at FarmingTracker.ItemDetailsSetter.<SetItemDetailsFromApi>d__0.MoveNext() in C:\Dev\blish\BlishHud-FarmingTracker\FarmingTracker\Details\ItemDetailsSetter.cs:line 33
   --- End of inner exception stack trace ---
   at FarmingTracker.ItemDetailsSetter.<SetItemDetailsFromApi>d__0.MoveNext() in C:\Dev\blish\BlishHud-FarmingTracker\FarmingTracker\Details\ItemDetailsSetter.cs:line 43
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.GetResult()
   at FarmingTracker.StatsSetter.<SetDetailsAndProfitFromApi>d__0.MoveNext() in C:\Dev\blish\BlishHud-FarmingTracker\FarmingTracker\Details\StatsSetter.cs:line 19
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.GetResult()
   at FarmingTracker.SummaryTabView.<UpdateStatsInModel>d__11.MoveNext() in C:\Dev\blish\BlishHud-FarmingTracker\FarmingTracker\SessionSummary\SummaryTabView.cs:line 288
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.GetResult()
   at FarmingTracker.SummaryTabView.<UpdateStats>d__7.MoveNext() in C:\Dev\blish\BlishHud-FarmingTracker\FarmingTracker\SessionSummary\SummaryTabView.cs:line 200
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

1 participant