Closed gigimatto88 closed 2 years ago
I have exactly the same issue. reproducible with package versions 4.0.3, 4.0.4, 4.0.5 (Jan 19, 2021)
looks like Google changed something so that old code does not work any more
Also getting an exception similar to this which I believe is deserialization error which no longer allows me to call the API's on the Firebase.Database library... Error converting value False to type 'MyApp.Business.Person'.
How it this even possible?
My Method looks like this:
public async Task<Person?> GetPersonAsync(string uid)
{
FirebaseObject<Person> person = (await _firebaseClient
.Child(nameof(Person))
.OnceAsync<Person>().ConfigureAwait(false)).SingleOrDefault(person => person.Object.UserInfo.Uid == uid);
return person.Object;
}
Newtonsoft.Json.JsonSerializationException: Error converting value False to type 'MyApp.Business.Person'. Path 'HasPhotoUrl', line 1, position 158. ---> System.ArgumentException: Could not cast or convert from System.Boolean to MyApp.Business.Person.
at Newtonsoft.Json.Utilities.ConvertUtils.EnsureTypeAssignable (System.Object value, System.Type initialType, System.Type targetType) [0x00061] in <2073514815234917a5e8f91b0b239405>:0
at Newtonsoft.Json.Utilities.ConvertUtils.ConvertOrCast (System.Object initialValue, System.Globalization.CultureInfo culture, System.Type targetType) [0x00036] in <2073514815234917a5e8f91b0b239405>:0
at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.EnsureType (Newtonsoft.Json.JsonReader reader, System.Object value, System.Globalization.CultureInfo culture, Newtonsoft.Json.Serialization.JsonContract contract, System.Type targetType) [0x00114] in <2073514815234917a5e8f91b0b239405>:0
--- End of inner exception stack trace ---
at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.EnsureType (Newtonsoft.Json.JsonReader reader, System.Object value, System.Globalization.CultureInfo culture, Newtonsoft.Json.Serialization.JsonContract contract, System.Type targetType) [0x00146] in <2073514815234917a5e8f91b0b239405>:0
at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateValueInternal (Newtonsoft.Json.JsonReader reader, System.Type objectType, Newtonsoft.Json.Serialization.JsonContract contract, Newtonsoft.Json.Serialization.JsonProperty member, Newtonsoft.Json.Serialization.JsonContainerContract containerContract, Newtonsoft.Json.Serialization.JsonProperty containerMember, System.Object existingValue) [0x0009b] in <2073514815234917a5e8f91b0b239405>:0
at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.PopulateDictionary (System.Collections.IDictionary dictionary, Newtonsoft.Json.JsonReader reader, Newtonsoft.Json.Serialization.JsonDictionaryContract contract, Newtonsoft.Json.Serialization.JsonProperty containerProperty, System.String id) [0x0024e] in <2073514815234917a5e8f91b0b239405>:0
at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateObject (Newtonsoft.Json.JsonReader reader, System.Type objectType, Newtonsoft.Json.Serialization.JsonContract contract, Newtonsoft.Json.Serialization.JsonProperty member, Newtonsoft.Json.Serialization.JsonContainerContract containerContract, Newtonsoft.Json.Serialization.JsonProperty containerMember, System.Object existingValue) [0x002b7] in <2073514815234917a5e8f91b0b239405>:0
at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateValueInternal (Newtonsoft.Json.JsonReader reader, System.Type objectType, Newtonsoft.Json.Serialization.JsonContract contract, Newtonsoft.Json.Serialization.JsonProperty member, Newtonsoft.Json.Serialization.JsonContainerContract containerContract, Newtonsoft.Json.Serialization.JsonProperty containerMember, System.Object existingValue) [0x0006d] in <2073514815234917a5e8f91b0b239405>:0
at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.Deserialize (Newtonsoft.Json.JsonReader reader, System.Type objectType, System.Boolean checkAdditionalContent) [0x000db] in <2073514815234917a5e8f91b0b239405>:0
at Newtonsoft.Json.JsonSerializer.DeserializeInternal (Newtonsoft.Json.JsonReader reader, System.Type objectType) [0x00054] in <2073514815234917a5e8f91b0b239405>:0
at Newtonsoft.Json.JsonSerializer.Deserialize (Newtonsoft.Json.JsonReader reader, System.Type objectType) [0x00000] in <2073514815234917a5e8f91b0b239405>:0
at Newtonsoft.Json.JsonConvert.DeserializeObject (System.String value, System.Type type, Newtonsoft.Json.JsonSerializerSettings settings) [0x0002d] in <2073514815234917a5e8f91b0b239405>:0
at Newtonsoft.Json.JsonConvert.DeserializeObject[T] (System.String value, Newtonsoft.Json.JsonSerializerSettings settings) [0x00000] in <2073514815234917a5e8f91b0b239405>:0
at Firebase.Database.Http.HttpClientExtensions.GetObjectCollectionAsync[T] (System.Net.Http.HttpClient client, System.String requestUri, Newtonsoft.Json.JsonSerializerSettings jsonSerializerSettings) [0x00140] in <d27c522a7ecc437a9802ee0b4650ca23>:0
[0:] END INNER EXCEPTION########################################
[0:] START INNER EXCEPTION########################################
[0:] System.ArgumentException: Could not cast or convert from System.Boolean to MyApp.Business.Person.
at Newtonsoft.Json.Utilities.ConvertUtils.EnsureTypeAssignable (System.Object value, System.Type initialType, System.Type targetType) [0x00061] in <2073514815234917a5e8f91b0b239405>:0
at Newtonsoft.Json.Utilities.ConvertUtils.ConvertOrCast (System.Object initialValue, System.Globalization.CultureInfo culture, System.Type targetType) [0x00036] in <2073514815234917a5e8f91b0b239405>:0
at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.EnsureType (Newtonsoft.Json.JsonReader reader, System.Object value, System.Globalization.CultureInfo culture, Newtonsoft.Json.Serialization.JsonContract contract, System.Type targetType) [0x00114] in <2073514815234917a5e8f91b0b239405>:0
[0:] END INNER EXCEPTION########################################
@bezysoftware is this something that can be looked into? The current implementation for querying firebase database doesn't work at all. I rolled back my code from a few months ago about last year when my code was definitely working fine and the same issue was reproduced when I tried to query database on firebase. I think something in the deserialization process is throwing an exception perhaps how firebase now returns data on its API's but for the last few months this has not worked at all.
I am happy to provide what's needed to help resolve this but from the above previous comment the stack trace is providing a clue to the deserialization, I can also note that I added this package directly to my project and also the Newtonsoft.Json project and there was definitely an issue on the deserialization in the Newtonsoft.Json. Its worth what is being returned from firebase API's and see if anything has changed.
@Astromarina
looks like Google changed something so that old code does not work any more
Do you have a link to this somewhere? Keen to know what changed.
As a side not this issue is reproducible on every version not just those you mentioned.
Hi @bezysoftware final call from us if this issue will be looked at before we look into shifting to an alternative to firebase.
Can't you use Oncesingleasync to access a single object?
From: Leonard @.> Sent: Saturday, June 19, 2021 8:56:48 AM To: step-up-labs/firebase-database-dotnet @.> Cc: Tomas Bezouska @.>; Mention @.> Subject: Re: [step-up-labs/firebase-database-dotnet] Why am i getting this: 'Exception occured while processing the request.' (#259)
Hi @bezysoftwarehttps://github.com/bezysoftware final call for use if this issue will be looked at before we look into shifting to an alternative to firebase.
— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHubhttps://github.com/step-up-labs/firebase-database-dotnet/issues/259#issuecomment-864366350, or unsubscribehttps://github.com/notifications/unsubscribe-auth/ABOTMEGECKIOFNYGJFOBSA3TTQ5TBANCNFSM4WI2CB4Q.
@bezysoftware thanks for getting back to me. I can confirm that OnceSingleAsync
does not work same as OnceSingle
. I'm willing to bet as @Astromarina mentioned that Google changed something and these API's now longer work.
To summarise I tried the following code
var all = await _firebaseClient.Child(nameof(Person)).OnceSingleAsync<Person>().ConfigureAwait(false);
And got the following (omitted some sensative data)
Resolved pending breakpoint at '/Users/TestAppServices/FirebaseService.cs:202,1' to void TestApp.Services.FirebaseService.<GetPersonAsync>d__14.MoveNext () [0x000d9].
[EGL_emulation] eglMakeCurrent: 0xe877e740: ver 3 0 (tinfo 0xb35b0aa0)
START MAIN EXCEPTION########################################
Firebase.Database.FirebaseException: Exception occured while processing the request.
Url: https://TestApp-*****.firebaseio.com/Person/.json?auth=*******************************************
Request Data:
Response: {"AppSettings":{"AllowInChat":false,"AllowUsersOptOut":false,"AllowUsersOptOutAndSwitch":false,"ShouldNotifyWhenFull":false},"FcmToken":"","Location":"","LoginType":"","Phone":"","UserInfo":{"DisplayName":"leonard Harris","Email":"******","IsAnonymous":false,"IsEmailVerified":false,"Uid":"s6uhrtJ1bvb8HJ4bAkUhaHp7Ehy1"},"UserStatusType":""} ---> Newtonsoft.Json.JsonSerializationException: Error converting value "" to type 'TestApp.Types.LoginType'. Path 'LoginType', line 1, position 167. ---> System.ArgumentException: Must specify valid information for parsing in the string.
at Newtonsoft.Json.Utilities.EnumUtils.ParseEnum (System.Type enumType, Newtonsoft.Json.Serialization.NamingStrategy namingStrategy, System.String value, System.Boolean disallowNumber) [0x000ae] in <7ca8898b690a4181a32a9cf767cedb1e>:0
at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.EnsureType (Newtonsoft.Json.JsonReader reader, System.Object value, System.Globalization.CultureInfo culture, Newtonsoft.Json.Serialization.JsonContract contract, System.Type targetType) [0x00054] in <7ca8898b690a4181a32a9cf767cedb1e>:0
--- End of inner exception stack trace ---
at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.EnsureType (Newtonsoft.Json.JsonReader reader, System.Object value, System.Globalization.CultureInfo culture, Newtonsoft.Json.Serialization.JsonContract contract, System.Type targetType) [0x00146] in <7ca8898b690a4181a32a9cf767cedb1e>:0
at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateValueInternal (Newtonsoft.Json.JsonReader reader, System.Type objectType, Newtonsoft.Json.Serialization.JsonContract contract, Newtonsoft.Json.Serialization.JsonProperty member, Newtonsoft.Json.Serialization.JsonContainerContract containerContract, Newtonsoft.Json.Serialization.JsonProperty containerMember, System.Object existingValue) [0x000dc] in <7ca8898b690a4181a32a9cf767cedb1e>:0
at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.SetPropertyValue (Newtonsoft.Json.Serialization.JsonProperty property, Newtonsoft.Json.JsonConverter propertyConverter, Newtonsoft.Json.Serialization.JsonContainerContract containerContract, Newtonsoft.Json.Serialization.JsonProperty containerProperty, Newtonsoft.Json.JsonReader reader, System.Object target) [0x00065] in <7ca8898b690a4181a32a9cf767cedb1e>:0
at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.PopulateObject (System.Object newObject, Newtonsoft.Json.JsonReader reader, Newtonsoft.Json.Serialization.JsonObjectContract contract, Newtonsoft.Json.Serialization.JsonProperty member, System.String id) [0x00280] in <7ca8898b690a4181a32a9cf767cedb1e>:0
at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateObject (Newtonsoft.Json.JsonReader reader, System.Type objectType, Newtonsoft.Json.Serialization.JsonContract contract, Newtonsoft.Json.Serialization.JsonProperty member, Newtonsoft.Json.Serialization.JsonContainerContract containerContract, Newtonsoft.Json.Serialization.JsonProperty containerMember, System.Object existingValue) [0x00161] in <7ca8898b690a4181a32a9cf767cedb1e>:0
at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateValueInternal (Newtonsoft.Json.JsonReader reader, System.Type objectType, Newtonsoft.Json.Serialization.JsonContract contract, Newtonsoft.Json.Serialization.JsonProperty member, Newtonsoft.Json.Serialization.JsonContainerContract containerContract, Newtonsoft.Json.Serialization.JsonProperty containerMember, System.Object existingValue) [0x0006d] in <7ca8898b690a4181a32a9cf767cedb1e>:0
at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.Deserialize (Newtonsoft.Json.JsonReader reader, System.Type objectType, System.Boolean checkAdditionalContent) [0x000db] in <7ca8898b690a4181a32a9cf767cedb1e>:0
at Newtonsoft.Json.JsonSerializer.DeserializeInternal (Newtonsoft.Json.JsonReader reader, System.Type objectType) [0x00054] in <7ca8898b690a4181a32a9cf767cedb1e>:0
at Newtonsoft.Json.JsonSerializer.Deserialize (Newtonsoft.Json.JsonReader reader, System.Type objectType) [0x00000] in <7ca8898b690a4181a32a9cf767cedb1e>:0
at Newtonsoft.Json.JsonConvert.DeserializeObject (System.String value, System.Type type, Newtonsoft.Json.JsonSerializerSettings settings) [0x0002d] in <7ca8898b690a4181a32a9cf767cedb1e>:0
at Newtonsoft.Json.JsonConvert.DeserializeObject[T] (System.String value, Newtonsoft.Json.JsonSerializerSettings settings) [0x00000] in <7ca8898b690a4181a32a9cf767cedb1e>:0
at Firebase.Database.Query.FirebaseQuery.OnceSingleAsync[T] (System.Nullable`1[T] timeout) [0x0021a] in <d27c522a7ecc437a9802ee0b4650ca23>:0
--- End of inner exception stack trace ---
at Firebase.Database.Query.FirebaseQuery.OnceSingleAsync[T] (System.Nullable`1[T] timeout) [0x00242] in <d27c522a7ecc437a9802ee0b4650ca23>:0
at TestApp.Services.FirebaseService.GetPersonAsync (System.String uid) [0x0006c] in /Users/TestAppServices/FirebaseService.cs:200
at TestApp.ViewModels.PrismInitialLoginPageViewModel.LoginAsync () [0x002ae] in /Users/TestAppViewModels/PrismInitialLoginPageViewModel.cs:93
END MAIN EXCEPTION########################################
START INNER EXCEPTION########################################
Newtonsoft.Json.JsonSerializationException: Error converting value "" to type 'TestApp.Types.LoginType'. Path 'LoginType', line 1, position 167. ---> System.ArgumentException: Must specify valid information for parsing in the string.
at Newtonsoft.Json.Utilities.EnumUtils.ParseEnum (System.Type enumType, Newtonsoft.Json.Serialization.NamingStrategy namingStrategy, System.String value, System.Boolean disallowNumber) [0x000ae] in <7ca8898b690a4181a32a9cf767cedb1e>:0
at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.EnsureType (Newtonsoft.Json.JsonReader reader, System.Object value, System.Globalization.CultureInfo culture, Newtonsoft.Json.Serialization.JsonContract contract, System.Type targetType) [0x00054] in <7ca8898b690a4181a32a9cf767cedb1e>:0
--- End of inner exception stack trace ---
at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.EnsureType (Newtonsoft.Json.JsonReader reader, System.Object value, System.Globalization.CultureInfo culture, Newtonsoft.Json.Serialization.JsonContract contract, System.Type targetType) [0x00146] in <7ca8898b690a4181a32a9cf767cedb1e>:0
at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateValueInternal (Newtonsoft.Json.JsonReader reader, System.Type objectType, Newtonsoft.Json.Serialization.JsonContract contract, Newtonsoft.Json.Serialization.JsonProperty member, Newtonsoft.Json.Serialization.JsonContainerContract containerContract, Newtonsoft.Json.Serialization.JsonProperty containerMember, System.Object existingValue) [0x000dc] in <7ca8898b690a4181a32a9cf767cedb1e>:0
at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.SetPropertyValue (Newtonsoft.Json.Serialization.JsonProperty property, Newtonsoft.Json.JsonConverter propertyConverter, Newtonsoft.Json.Serialization.JsonContainerContract containerContract, Newtonsoft.Json.Serialization.JsonProperty containerProperty, Newtonsoft.Json.JsonReader reader, System.Object target) [0x00065] in <7ca8898b690a4181a32a9cf767cedb1e>:0
at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.PopulateObject (System.Object newObject, Newtonsoft.Json.JsonReader reader, Newtonsoft.Json.Serialization.JsonObjectContract contract, Newtonsoft.Json.Serialization.JsonProperty member, System.String id) [0x00280] in <7ca8898b690a4181a32a9cf767cedb1e>:0
at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateObject (Newtonsoft.Json.JsonReader reader, System.Type objectType, Newtonsoft.Json.Serialization.JsonContract contract, Newtonsoft.Json.Serialization.JsonProperty member, Newtonsoft.Json.Serialization.JsonContainerContract containerContract, Newtonsoft.Json.Serialization.JsonProperty containerMember, System.Object existingValue) [0x00161] in <7ca8898b690a4181a32a9cf767cedb1e>:0
at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateValueInternal (Newtonsoft.Json.JsonReader reader, System.Type objectType, Newtonsoft.Json.Serialization.JsonContract contract, Newtonsoft.Json.Serialization.JsonProperty member, Newtonsoft.Json.Serialization.JsonContainerContract containerContract, Newtonsoft.Json.Serialization.JsonProperty containerMember, System.Object existingValue) [0x0006d] in <7ca8898b690a4181a32a9cf767cedb1e>:0
at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.Deserialize (Newtonsoft.Json.JsonReader reader, System.Type objectType, System.Boolean checkAdditionalContent) [0x000db] in <7ca8898b690a4181a32a9cf767cedb1e>:0
at Newtonsoft.Json.JsonSerializer.DeserializeInternal (Newtonsoft.Json.JsonReader reader, System.Type objectType) [0x00054] in <7ca8898b690a4181a32a9cf767cedb1e>:0
at Newtonsoft.Json.JsonSerializer.Deserialize (Newtonsoft.Json.JsonReader reader, System.Type objectType) [0x00000] in <7ca8898b690a4181a32a9cf767cedb1e>:0
at Newtonsoft.Json.JsonConvert.DeserializeObject (System.String value, System.Type type, Newtonsoft.Json.JsonSerializerSettings settings) [0x0002d] in <7ca8898b690a4181a32a9cf767cedb1e>:0
at Newtonsoft.Json.JsonConvert.DeserializeObject[T] (System.String value, Newtonsoft.Json.JsonSerializerSettings settings) [0x00000] in <7ca8898b690a4181a32a9cf767cedb1e>:0
at Firebase.Database.Query.FirebaseQuery.OnceSingleAsync[T] (System.Nullable`1[T] timeout) [0x0021a] in <d27c522a7ecc437a9802ee0b4650ca23>:0
END INNER EXCEPTION########################################
START INNER EXCEPTION########################################
System.ArgumentException: Must specify valid information for parsing in the string.
at Newtonsoft.Json.Utilities.EnumUtils.ParseEnum (System.Type enumType, Newtonsoft.Json.Serialization.NamingStrategy namingStrategy, System.String value, System.Boolean disallowNumber) [0x000ae] in <7ca8898b690a4181a32a9cf767cedb1e>:0
at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.EnsureType (Newtonsoft.Json.JsonReader reader, System.Object value, System.Globalization.CultureInfo culture, Newtonsoft.Json.Serialization.JsonContract contract, System.Type targetType) [0x00054] in <7ca8898b690a4181a32a9cf767cedb1e>:0
END INNER EXCEPTION########################################
[EGL_emulation] eglMakeCurrent: 0xe877e740: ver 3 0 (tinfo 0xb35b0aa0)
Thread finished: <Thread Pool> #13
The actual response looks good i.e.:
Response: {"AppSettings":{"AllowInChat":false,"AllowUsersOptOut":false,"AllowUsersOptOutAndSwitch":false,"ShouldNotifyWhenFull":false},"FcmToken":"","Location":"","LoginType":"","Phone":"","UserInfo":{"DisplayName":"leonard Harris","Email":"******","IsAnonymous":false,"IsEmailVerified":false,"Uid":"s6uhrtJ1bvb8HJ4bAkUhaHp7Ehy1"},"UserStatusType":""}
but looks like some serialisation issues occurring in Newtonsoft.Json:
Newtonsoft.Json.JsonSerializationException: Error converting value "" to type 'TestApp.Types.LoginType'. Path 'LoginType', line 1, position 167. ---> System.ArgumentException: Must specify valid information for parsing in the string.
at Newtonsoft.Json.Utilities.EnumUtils.ParseEnum
I think the error is pretty self-explanatory:
Error converting value "" to type 'TestApp.Types.LoginType'. Path 'LoginType', line 1, position 167
.
The library is using Newtonsoft.Json which is not able to deserialize empty string into LoginType
.
It's possible google was returning empty values as nulls, but now it returns actually empty string? Dunno
@bezysoftware your exactly right thats actually resolved the issue 👍 that issue is gone having following the link you provided. Thank you very much!
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.
Closing the issue due to inactivity. Feel free to re-open
When i query firebase with:
i get this exception:
This is my firebase:
This is my User model:
It seems to me a deserialization error but i can't figure out why.