Skip to content

Querying documents with DocumentReference and GeoPoint throws errors #3006

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
MichaelSolati opened this issue May 3, 2020 · 5 comments · Fixed by #3018
Closed

Querying documents with DocumentReference and GeoPoint throws errors #3006

MichaelSolati opened this issue May 3, 2020 · 5 comments · Fixed by #3018

Comments

@MichaelSolati
Copy link

MichaelSolati commented May 3, 2020

[REQUIRED] Describe your environment

  • Operating System version: macOS Catalina 10.15.4
  • Browser version: Chrome 81.0.4044.129
  • Firebase SDK version: 7.14.2
  • Firebase Product: firestore

[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
Copy link

ahsath commented May 4, 2020

I'm having the same issue

@var-const
Copy link
Contributor

var-const commented May 4, 2020

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
Copy link
Author

MichaelSolati commented May 4, 2020

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
Copy link
Contributor

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

@var-const
Copy link
Contributor

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

var-const added a commit that referenced this issue May 5, 2020
…dation (#3018)

Fix the regression introduced in #2784: a `GeoPoint` where at least one of the coordinates is zero doesn't marshal properly. This is because zeroes happen to be serialized as `undefined` (presumably because protos normally treat zero values and the absence of a value interchangeably) which then fails the strict input validation in `GeoPoint`.

Fixes #3006.
@firebase firebase locked and limited conversation to collaborators Jun 5, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants