Skip to content
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

Serializer does not check object for a prototype before calling hasOwnProperty() #732

Closed
lookfirst opened this issue Aug 14, 2019 · 5 comments · Fixed by #736
Closed

Serializer does not check object for a prototype before calling hasOwnProperty() #732

lookfirst opened this issue Aug 14, 2019 · 5 comments · Fixed by #736
Assignees
Labels
api: firestore Issues related to the googleapis/nodejs-firestore API. priority: p2 Moderately-important priority. Fix may not be included in next release. type: bug Error or flaw in code with unintended results or allowing sub-optimal usage patterns.

Comments

@lookfirst
Copy link

lookfirst commented Aug 14, 2019

Latest version.

https://github.com/googleapis/nodejs-firestore/search?q=hasOwnProperty&unscoped_q=hasOwnProperty

The bigger issue is that if I try to save an object into the firestore was created with Object.create(null), the save fails due to the object not having hasOwnProperty. It is quite difficult to debug as a result

Related reasoning and background and example code:

@yoshi-automation yoshi-automation added the triage me I really want to be triaged. label Aug 14, 2019
@schmidt-sebastian schmidt-sebastian added the type: bug Error or flaw in code with unintended results or allowing sub-optimal usage patterns. label Aug 16, 2019
@thebrianchen thebrianchen self-assigned this Aug 16, 2019
@yoshi-automation yoshi-automation added the 🚨 This issue needs some love. label Aug 19, 2019
@lookfirst
Copy link
Author

Exact reasoning: graphql/express-graphql#177 (comment)

@bcoe bcoe added priority: p2 Moderately-important priority. Fix may not be included in next release. type: bug Error or flaw in code with unintended results or allowing sub-optimal usage patterns. and removed type: bug Error or flaw in code with unintended results or allowing sub-optimal usage patterns. 🚨 This issue needs some love. triage me I really want to be triaged. labels Aug 20, 2019
@thebrianchen
Copy link

@praveenqlogic01 Thanks for your PR! We'll review this, make some changes to the PR, and then merge it in.

@thebrianchen
Copy link

@lookfirst I've been trying to reproduce the error in tests on our master branch, but it seems that calling update, set, or create with Object.create(null) or {foo: Object.create(null)} all seem to work fine.

What is your entry point that causes failures?

@lookfirst
Copy link
Author

I think you'd need to pass in a top level object to set and that object is going to need to have some properties on it.

const foo = Object.create(null);
foo.bar = 'ack';
set(foo);

Not sure if this has an effect on the codepath, but I also run everything through a transaction.

There is an example in this comment via this gist to build the object which would be passed through to the set.

@lookfirst
Copy link
Author

@thebrianchen Thank you so much!

@google-cloud-label-sync google-cloud-label-sync bot added the api: firestore Issues related to the googleapis/nodejs-firestore API. label Jan 31, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api: firestore Issues related to the googleapis/nodejs-firestore API. priority: p2 Moderately-important priority. Fix may not be included in next release. type: bug Error or flaw in code with unintended results or allowing sub-optimal usage patterns.
Projects
None yet
5 participants