question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Firestore - DocumentSnapshot.ConvertTo fails with ArgumentException

See original GitHub issue

I have found an interesting issue when using Firestore (currently 1.0.0-beta08) in my C# project. Calling ConvertTo<T>() from a document snapshot fails when T does not contain properties to accommodate all document’s fields. An ArgumentException is thrown in this case.

This is how the issue can be reproduced:

Given the following POCO class:

[FirestoreData()]
private class MyDocument
{
    [FirestoreProperty()]
    public string Name { get; set; }
}

And the following Firestore document:

{
   "Name": "Some Name",
   "LastName": "Some Last Name"
}

An ArgumentException is thrown when calling:

var myDocument = documentSnapshot.ConvertTo<MyDocument>();

If this behavior has been intentionally implemented, it should be at least configurable (either by passing an argument to ConvertTo<T>() or by providing parameters to FirestoreDataAttribute). It completely breaks the flexibility of a document database, since adding new fields to the documents forcibly requires changing the code base. Backwards compatibility becomes then a hard task if not impossible.

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Reactions:1
  • Comments:7

github_iconTop GitHub Comments

1reaction
jskeetcommented, Oct 2, 2022

@mikenlanggio: It looks like that isn’t using the Google.Cloud.Firestore library which is in this repo, but Firebase.Firestore, which is a separate codebase, supported by the Firebase team. I suggest you follow the steps in the Firebase support page - I’m afraid there are too many possibility for a Unity-specific or Firebase.Firestore-specific problem for me to help here.

0reactions
mikenlanggiocommented, Oct 2, 2022

@mikenlanggio: It looks like that isn’t using the Google.Cloud.Firestore library which is in this repo, but Firebase.Firestore, which is a separate codebase, supported by the Firebase team. I suggest you follow the steps in the Firebase support page - I’m afraid there are too many possibility for a Unity-specific or Firebase.Firestore-specific problem for me to help here.

Thank you for your quick reply. Have a nice day ^^

Read more comments on GitHub >

github_iconTop Results From Across the Web

Updating a document in Firebase Firestore from .Net Core ...
Problem. Update does not happen due to problem with conversion. Exception: Unable to create converter for type Models.Participant. Question.
Read more >
Firebase.Firestore.DocumentSnapshot Class Reference
ConvertTo < T >(ServerTimestampBehavior serverTimestampBehavior). T. Deserializes the document data as the specified type. Equals(object obj). override bool.
Read more >
Data model
The Firestore data model revolves around documents and collections. Collections contain documents, which can contain more collections.
Read more >
A Stranger error:Cloud Firestore DocumentSnapshot. ...
You received this message because you are subscribed to the Google Groups "google-cloud-firestore-discuss" group. To unsubscribe from this group ...
Read more >
Firebase Firestore Task<DocumentSnapshot>.Result. ...
I'm new on Firebase Firestore and I trying to check if certain document exist on my database, but my boolean always return false....
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found