Skip to content

Conversation

jbloxham
Copy link
Contributor

I have a slightly unusual express server setup in which the client provides their user ID in the req.user field, then a middleware replaces this with the corresponding user entry from a database, thus populating req.user.email and req.user.id. Unfortunately, it turns out that sentry is unable to extract these fields automatically, because they are defined in the prototype of the req.user object, and thus are ignored by hasOwnProperty. Changing this to a simple in operator fixes this issue. I don't see a good reason why hasOwnProperty should be preferred to in here, as the extracted fields are configurable anyways.

I have a slightly unusual express server setup in which the client provides their user ID in the `req.user` field, then a middleware replaces this with the corresponding user entry from a database, thus populating `req.user.email` and `req.user.id`. Unfortunately, it turns out that sentry is unable to extract these fields automatically, because they are defined in the prototype of the `req.user` object, and thus are ignored by `hasOwnProperty`. Changing this to a simple `in` operator fixes this issue. I don't see a good reason why `hasOwnProperty` should be preferred to `in` here, as the extracted fields are configurable anyways.
@kamilogorek
Copy link
Contributor

I don't see a good reason why hasOwnProperty should be preferred to in here, as the extracted fields are configurable anyways.

True. Thanks for the PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants