Skip to content

Fix GeoPoint field values with a zero coordinate failing input validation #3018

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

Merged
merged 3 commits into from
May 5, 2020

Conversation

var-const
Copy link
Contributor

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.

value.geoPointValue!.latitude!,
value.geoPointValue!.longitude!
);
// `geoPointValue` stores zeroes as undefined, which will fail
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sebastian, can you think of any other types that might be affected? Timestamp, I think, isn't.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Timestamp goes through normalizeNumber() which turns undefined into 0. Do you want to follow this pattern here as well and invoke normalizeNumber()? It also correctly handles NaN and Infinity, which should never be part of a GeoPoint, but who knows where 2020 is going to take us.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done (and extracted into a small helper function for consistency with Timestamp et al.).

@var-const var-const merged commit fd12d77 into firebase:master May 5, 2020
@var-const var-const deleted the varconst/fix-geo-point-zero-2 branch May 5, 2020 23:12
@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 this pull request may close these issues.

Querying documents with DocumentReference and GeoPoint throws errors
2 participants