Skip to content

iOS float / non-integer averageUserRatingForCurrentVersion/averageUserRating causes exception in GetLatestVersionAsync #10

Description

@phdonnelly-porky

The current live JSON for our iOS app has float values for both of these in the JSON returned from apple at https://itunes.apple.com/lookup?bundleId=ourbundle&country=us but these are both defined as ints in src/libs/Maui.AppStoreInfo/Platforms/iOS/Sdk/LookupResult.cs which caused a deserialize exception when called.

Stacktrace:

System.Text.Json.JsonException: DeserializeUnableToConvertValue, System.Int32 Path: $.results[0].averageUserRatingForCurrentVersion |          
 LineNumber: 10 | BytePositionInLine: 4229.|System.Text.Json.JsonException: DeserializeUnableToConvertValue, System.Int32 Path: $.results[0].averageUserRatingForCurrentVersion | LineNumber: 10 | BytePositionInLine:  
 4229.                                                                                                                                                                                                                  
    ---> System.FormatException: FormatInt32                                                                                                                                                                            
      at System.Text.Json.ThrowHelper.ThrowFormatException(NumericType )                                                                                                                                                
      at System.Text.Json.Serialization.Converters.Int32Converter.Read(Utf8JsonReader& , Type , JsonSerializerOptions )                                                                                                 
      at System.Text.Json.Serialization.Metadata.JsonPropertyInfo`1[[System.Int32, System.Private.CoreLib, Version=10.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]].ReadJsonAndSetMember(Object ,           
 ReadStack& , Utf8JsonReader& )                                                                                                                                                                                         
      at System.Text.Json.Serialization.Converters.ObjectDefaultConverter`1[[Maui.AppStores.Internal.LookupResult, Maui.AppStoreInfo, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]].OnTryRead(Utf8JsonReader& 
 , Type , JsonSerializerOptions , ReadStack& , LookupResult& )                                                                                                                                                          
      at System.Text.Json.Serialization.Converters.JsonMetadataServicesConverter`1[[Maui.AppStores.Internal.LookupResult, Maui.AppStoreInfo, Version=1.0.0.0, Culture=neutral,                                          
 PublicKeyToken=null]].OnTryRead(Utf8JsonReader& , Type , JsonSerializerOptions , ReadStack& , LookupResult& )                                                                                                          
      at System.Text.Json.Serialization.JsonConverter`1[[Maui.AppStores.Internal.LookupResult, Maui.AppStoreInfo, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]].TryRead(Utf8JsonReader& , Type ,              
 JsonSerializerOptions , ReadStack& , LookupResult& , Boolean& )                                                                                                                                                        
      at System.Text.Json.Serialization.JsonCollectionConverter`2[[System.Collections.Generic.List`1[[Maui.AppStores.Internal.LookupResult, Maui.AppStoreInfo, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]], 
 System.Private.CoreLib, Version=10.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e],[Maui.AppStores.Internal.LookupResult, Maui.AppStoreInfo, Version=1.0.0.0, Culture=neutral,                                
 PublicKeyToken=null]].OnTryRead(Utf8JsonReader& , Type , JsonSerializerOptions , ReadStack& , List`1& )                                                                                                                
      at System.Text.Json.Serialization.Converters.JsonMetadataServicesConverter`1[[System.Collections.Generic.List`1[[Maui.AppStores.Internal.LookupResult, Maui.AppStoreInfo, Version=1.0.0.0, Culture=neutral,       
 PublicKeyToken=null]], System.Private.CoreLib, Version=10.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]].OnTryRead(Utf8JsonReader& , Type , JsonSerializerOptions , ReadStack& , List`1& )                  
      at System.Text.Json.Serialization.JsonConverter`1[[System.Collections.Generic.List`1[[Maui.AppStores.Internal.LookupResult, Maui.AppStoreInfo, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]],           
 System.Private.CoreLib, Version=10.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]].TryRead(Utf8JsonReader& , Type , JsonSerializerOptions , ReadStack& , List`1& , Boolean& )                                
      at System.Text.Json.Serialization.Metadata.JsonPropertyInfo`1[[System.Collections.Generic.List`1[[Maui.AppStores.Internal.LookupResult, Maui.AppStoreInfo, Version=1.0.0.0, Culture=neutral,                      
 PublicKeyToken=null]], System.Private.CoreLib, Version=10.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]].ReadJsonAndSetMember(Object , ReadStack& , Utf8JsonReader& )                                       
      at System.Text.Json.Serialization.Converters.ObjectDefaultConverter`1[[Maui.AppStores.Internal.LookupResponse, Maui.AppStoreInfo, Version=1.0.0.0, Culture=neutral,                                               
 PublicKeyToken=null]].OnTryRead(Utf8JsonReader& , Type , JsonSerializerOptions , ReadStack& , LookupResponse& )                                                                                                        
      at System.Text.Json.Serialization.Converters.JsonMetadataServicesConverter`1[[Maui.AppStores.Internal.LookupResponse, Maui.AppStoreInfo, Version=1.0.0.0, Culture=neutral,                                        
 PublicKeyToken=null]].OnTryRead(Utf8JsonReader& , Type , JsonSerializerOptions , ReadStack& , LookupResponse& )                                                                                                        
      at System.Text.Json.Serialization.JsonConverter`1[[Maui.AppStores.Internal.LookupResponse, Maui.AppStoreInfo, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]].TryRead(Utf8JsonReader& , Type ,            
 JsonSerializerOptions , ReadStack& , LookupResponse& , Boolean& )                                                                                                                                                      
      at System.Text.Json.Serialization.JsonConverter`1[[Maui.AppStores.Internal.LookupResponse, Maui.AppStoreInfo, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]].ReadCore(Utf8JsonReader& , LookupResponse&  
 , JsonSerializerOptions , ReadStack& )                                                                                                                                                                                 
      Exception_EndOfInnerExceptionStack                                                                                                                                                                                
      at System.Text.Json.ThrowHelper.ReThrowWithPath(ReadStack& , Utf8JsonReader& , Exception )                                                                                                                        
      at System.Text.Json.Serialization.JsonConverter`1[[Maui.AppStores.Internal.LookupResponse, Maui.AppStoreInfo, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]].ReadCore(Utf8JsonReader& , LookupResponse&  
 , JsonSerializerOptions , ReadStack& )                                                                                                                                                                                 
      at System.Text.Json.Serialization.Metadata.JsonTypeInfo`1[[Maui.AppStores.Internal.LookupResponse, Maui.AppStoreInfo, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]].Deserialize(Utf8JsonReader& ,       
 ReadStack& )                                                                                                                                                                                                           
      at System.Text.Json.JsonSerializer.ReadFromSpan[LookupResponse](ReadOnlySpan`1 , JsonTypeInfo`1 , Nullable`1 )                                                                                                    
      at System.Text.Json.JsonSerializer.ReadFromSpan[LookupResponse](ReadOnlySpan`1 , JsonTypeInfo`1 )                                                                                                                 
      at System.Text.Json.JsonSerializer.Deserialize[LookupResponse](String , JsonTypeInfo`1 )                                                                                                                          
      at Maui.AppStores.Internal.HttpClientExtensions.LookupAsync(HttpClient , String , String , CancellationToken )                                                                                                    
      at Maui.AppStores.AppStoreInfoImplementation.GetInformationAsync(CancellationToken )                                                                                                                              
      at Maui.AppStores.IAppStoreInfo.GetLatestVersionAsync(CancellationToken )                                                                                                                                         
      at Maui.AppStores.IAppStoreInfo.IsUsingLatestVersionAsync(Version , CancellationToken )

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions