K1llMan / Yandex.Music.Api

Yandex.Music API (Unofficial) for .Net
GNU General Public License v3.0
93 stars 20 forks source link

Ошибка десериализации при вызове метода Landing.GetFeedAsync #22

Closed Fooxboy closed 1 year ago

Fooxboy commented 1 year ago

Как я вызывал: var feed = await _yandexApi.Landing.GetFeedAsync(_storage); Где, _yandexApiэкземпляр класса YandexMusicApi

Стек трейс:

Ошибка десериализации System.Exception: Ошибка десериализации типа "last-week-personal-popular-tracks".
 ---> System.ArgumentException: Could not convert 'last-week-personal-popular-tracks' to YFeedEventType.
 ---> Newtonsoft.Json.JsonSerializationException: Error converting value "last-week-personal-popular-tracks" to type 'Yandex.Music.Api.Models.Feed.Event.YFeedEventType'. Path '[1].typeForFrom', line 1, position 30827.
 ---> System.ArgumentException: Requested value 'last-week-personal-popular-tracks' was not found.
   at Newtonsoft.Json.Utilities.EnumUtils.ParseEnum(Type enumType, NamingStrategy namingStrategy, String value, Boolean disallowNumber)
   at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.EnsureType(JsonReader reader, Object value, CultureInfo culture, JsonContract contract, Type targetType)
   --- End of inner exception stack trace ---
   at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.EnsureType(JsonReader reader, Object value, CultureInfo culture, JsonContract contract, Type targetType)
   at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateValueInternal(JsonReader reader, Type objectType, JsonContract contract, JsonProperty member, JsonContainerContract containerContract, JsonProperty containerMember, Object existingValue)
   at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.Deserialize(JsonReader reader, Type objectType, Boolean checkAdditionalContent)
   at Newtonsoft.Json.JsonSerializer.DeserializeInternal(JsonReader reader, Type objectType)
   at Newtonsoft.Json.JsonSerializer.Deserialize(JsonReader reader, Type objectType)
   at Newtonsoft.Json.Linq.JToken.ToObject(Type objectType, JsonSerializer jsonSerializer)
   at Newtonsoft.Json.Linq.JToken.ToObject(Type objectType)
   --- End of inner exception stack trace ---
   at Newtonsoft.Json.Linq.JToken.ToObject(Type objectType)
   at Newtonsoft.Json.Linq.JToken.ToObject[T]()
   at Yandex.Music.Api.Models.Feed.Event.YFeedEventConverter.GetEvent(JToken jObject)
   --- End of inner exception stack trace ---
   at Yandex.Music.Api.Models.Feed.Event.YFeedEventConverter.GetEvent(JToken jObject)
   at System.Linq.Enumerable.SelectIListIterator`2.ToList()
   at Yandex.Music.Api.Models.Feed.Event.YFeedEventConverter.ReadJson(JsonReader reader, Type objectType, Object existingValue, JsonSerializer serializer)
   at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.DeserializeConvertable(JsonConverter converter, JsonReader reader, Type objectType, Object existingValue)
   at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.SetPropertyValue(JsonProperty property, JsonConverter propertyConverter, JsonContainerContract containerContract, JsonProperty containerProperty, JsonReader reader, Object target)
   at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.PopulateObject(Object newObject, JsonReader reader, JsonObjectContract contract, JsonProperty member, String id)
   at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateObject(JsonReader reader, Type objectType, JsonContract contract, JsonProperty member, JsonContainerContract containerContract, JsonProperty containerMember, Object existingValue)
   at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateValueInternal(JsonReader reader, Type objectType, JsonContract contract, JsonProperty member, JsonContainerContract containerContract, JsonProperty containerMember, Object existingValue)
   at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.PopulateList(IList list, JsonReader reader, JsonArrayContract contract, JsonProperty containerProperty, String id)
   at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateList(JsonReader reader, Type objectType, JsonContract contract, JsonProperty member, Object existingValue, String id)
   at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateValueInternal(JsonReader reader, Type objectType, JsonContract contract, JsonProperty member, JsonContainerContract containerContract, JsonProperty containerMember, Object existingValue)
   at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.SetPropertyValue(JsonProperty property, JsonConverter propertyConverter, JsonContainerContract containerContract, JsonProperty containerProperty, JsonReader reader, Object target)
   at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.PopulateObject(Object newObject, JsonReader reader, JsonObjectContract contract, JsonProperty member, String id)
   at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateObject(JsonReader reader, Type objectType, JsonContract contract, JsonProperty member, JsonContainerContract containerContract, JsonProperty containerMember, Object existingValue)
   at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateValueInternal(JsonReader reader, Type objectType, JsonContract contract, JsonProperty member, JsonContainerContract containerContract, JsonProperty containerMember, Object existingValue)
   at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.SetPropertyValue(JsonProperty property, JsonConverter propertyConverter, JsonContainerContract containerContract, JsonProperty containerProperty, JsonReader reader, Object target)
   at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.PopulateObject(Object newObject, JsonReader reader, JsonObjectContract contract, JsonProperty member, String id)
   at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateObject(JsonReader reader, Type objectType, JsonContract contract, JsonProperty member, JsonContainerContract containerContract, JsonProperty containerMember, Object existingValue)
   at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateValueInternal(JsonReader reader, Type objectType, JsonContract contract, JsonProperty member, JsonContainerContract containerContract, JsonProperty containerMember, Object existingValue)
   at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.Deserialize(JsonReader reader, Type objectType, Boolean checkAdditionalContent)
   at Newtonsoft.Json.JsonSerializer.DeserializeInternal(JsonReader reader, Type objectType)
   at Newtonsoft.Json.JsonSerializer.Deserialize(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 Yandex.Music.Api.Common.Providers.CommonRequestProvider.GetDataFromResponseAsync[T](YandexMusicApi api, HttpResponseMessage response)
K1llMan commented 1 year ago

Можно пример json с "last-week-personal-popular-tracks"? У меня такой тип события не приходил. Upd: начал присылать, проверю. Upd2: присылает, но не такой тип сообщения, с ним тоже ошибка.

K1llMan commented 1 year ago

Поправил сохранение ответов в отладке. Запустите вместе тесты AuthorizeTypes_ValidData_True и GetFeed_ValidData_True. В папке responses должны сохраниться ответы. Нужны данные по feed, чтобы подобрать корректную модель.

Fooxboy commented 1 year ago

Сейчас склонировал репу, запустил тесты, все успешно прошло, поэтому закрываю, скорее всего или яндекс передумал присылать это или Вы пофиксили в мастере, а в нугете устаревшая :/

K1llMan commented 1 year ago

Тест успешно прошёл, потому что ошибка обработалась, там немного по-другому настроил отлов ошибки, потому что с этой ошибкой данные не сохранялись. Необходимо именно директорию проверить на наличие файла.

Fooxboy commented 1 year ago

Там пусто image

K1llMan commented 1 year ago

Ок. Если будут возникать ошибки подобного рода, то можно сразу прикреплять файл с логом и содержимым ответа.