firebase / firebase-js-sdk

Firebase Javascript SDK
https://firebase.google.com/docs/web/setup
Other
4.82k stars 885 forks source link

Querying documents with `DocumentReference` and `GeoPoint` throws errors #3006

Closed MichaelSolati closed 4 years ago

MichaelSolati commented 4 years ago

[REQUIRED] Describe your environment

[REQUIRED] Describe the problem

Steps to reproduce:

Add a document to Firestore (doc1) with a GeoPoint set to 0, 0, take a reference to the added document (doc1) and add it as field in an array to a new document (doc2) as well as a GeoPoint set to 0, 0. Query for the second document (doc2) and try to get the data() of it. It will throw an error saying: FirebaseError: [code=invalid-argument]: Function GeoPoint() requires its first argument to be of type number, but it was: undefined.

However if you change the coordinates to 1, 1 there is no issue what so ever!

Relevant Code:

https://stackblitz.com/edit/firebase-js-sdk-3006?file=index.ts


Update, if any field of the GeoPoint is 0 this issue occurs.

ahsath commented 4 years ago

I'm having the same issue

var-const commented 4 years ago

Thanks for the bug report. Unfortunately, I cannot reproduce this issue locally. At first, I tried using Friendly Eats, which is in JavaScript. When that didn't work out, I downloaded the Stackblitz project you linked and ran it with ts-node:

{
  posts: [
    DocumentReference {
      _key: [DocumentKey],
      firestore: [Firestore],
      _converter: undefined,
      _firestoreClient: [FirestoreClient]
    }
  ],
  coordinates: GeoPoint { _lat: 0, _long: 0 }
}

I cannot debug the issue on Stackblitz. Would it be possible for you to prepare a repro case that can be run locally? I have a suspicion that the error is caused by something in the setup/environment (if it were within the SDK itself, it would have probably been reproduced on FriendlyEats). Does this issue happen outside of Stackblitz?

MichaelSolati commented 4 years ago

Thanks for the bug report. Unfortunately, I cannot reproduce this issue locally. At first, I tried using Friendly Eats, which is in JavaScript. When that didn't work out, I downloaded the Stackblitz project you linked and ran it with ts-node:

{
  posts: [
    DocumentReference {
      _key: [DocumentKey],
      firestore: [Firestore],
      _converter: undefined,
      _firestoreClient: [FirestoreClient]
    }
  ],
  coordinates: GeoPoint { _lat: 0, _long: 0 }
}

I cannot debug the issue on Stackblitz. Would it be possible for you to prepare a repro case that can be run locally? I have a suspicion that the error is caused by something in the setup/environment (if it were within the SDK itself, it would have probably been reproduced on FriendlyEats). Does this issue happen outside of Stackblitz?

I don't think it's a ts-node/StackBlitz specific issue... 😕

I've included a suuuper simple repo and have it running on GH Pages, the issue seems to persist.

var-const commented 4 years ago

Thank you! I can reproduce it now, will investigate further.

var-const commented 4 years ago

This is a regression introduced in 7.14.2. Thanks a lot for helping us catch it quickly!