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

Receiving a HTTP 500 when using a distinct query on nullable field #4540

Closed
j-koenig opened this issue Feb 2, 2018 · 5 comments
Closed

Receiving a HTTP 500 when using a distinct query on nullable field #4540

j-koenig opened this issue Feb 2, 2018 · 5 comments
Assignees
Labels
type:bug Impaired feature or lacking behavior that is likely assumed

Comments

@j-koenig
Copy link

j-koenig commented Feb 2, 2018

Issue Description

Parse-Server responds with a HTTP 500 when using a distinct query on the _User table using a field which is set to null on one or more objects.

Steps to reproduce

Setup a new parse-server instance and add a field of the type String to the table. Create a new user and set the newly created field to null for the new user. Use the new distinct query feature on that field.

Expected Results

The server should return an array with all distinct strings

Actual Outcome

The server responds with a HTTP 500

Environment Setup

  • Server

    • parse-server version: 2.7.2
    • Operating System: Amazon Linux 2017.09 v4.4.4
    • Hardware: EC2 t2.micro
    • Localhost or remote server: AWS
  • Database

    • MongoDB version: 3.2.13
    • Storage engine: wiredTiger
    • Hardware: EC2 t2.micro
    • Localhost or remote server: AWS

Logs/Trace

Uncaught internal server error. TypeError: Cannot convert undefined or null to object
    at cleanResultOfSensitiveUserInfo (/var/app/current/node_modules/parse-server/lib/RestQuery.js:422:10)
    at config.database.find.then.results (/var/app/current/node_modules/parse-server/lib/RestQuery.js:499:9)
    at process._tickDomainCallback (internal/process/next_tick.js:135:7) TypeError: Cannot convert undefined or null to object
    at cleanResultOfSensitiveUserInfo (/var/app/current/node_modules/parse-server/lib/RestQuery.js:422:10)
    at config.database.find.then.results (/var/app/current/node_modules/parse-server/lib/RestQuery.js:499:9)
    at process._tickDomainCallback (internal/process/next_tick.js:135:7)
@dplewis
Copy link
Member

dplewis commented Feb 2, 2018

Good catch! Would you like to open a PR for this issue?

@dplewis dplewis added the type:bug Impaired feature or lacking behavior that is likely assumed label Feb 7, 2018
@dplewis dplewis self-assigned this Feb 7, 2018
@dplewis
Copy link
Member

dplewis commented Feb 8, 2018

@flovilmart I have a PR ready for this but I wanted to verify something. I noticed a difference when setting a field from a value to null or undefined.

When using null the field is set.

{ $set: { fieldName: null, _updated_at: ... } }

When using undefined the field isn't updated.

{ $set: { _updated_at: ... } }

Is this proper behavior? This is specific for Mongo, they both update when using PG

@flovilmart
Copy link
Contributor

it boils down to bottom values, undefined is not serialized, this is an unset, in PG null or unset is the same right?

@j-koenig
Copy link
Author

@dplewis Sorry for not answering to your message and thanks for the PR :)

@jeffreyjackson
Copy link

how do we get a field back to 'undefined' when using unset in js sdk? now it sets it to null which isnt the same and breaks older versions. @flovilmart

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type:bug Impaired feature or lacking behavior that is likely assumed
Projects
None yet
Development

No branches or pull requests

4 participants