Skip to content

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

Closed

Description

@j-koenig

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)

Activity

  1. dplewis commented on Feb 2, 2018

    @dplewis
    Member

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

  2. added
    type:bugImpaired feature or lacking behavior that is likely assumed
    on Feb 7, 2018
  3. self-assigned this
    on Feb 7, 2018
  4. dplewis commented on Feb 8, 2018

    @dplewis
    Member

    @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

  5. flovilmart commented on Feb 8, 2018

    @flovilmart
    Contributor

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

  6. j-koenig commented on Feb 16, 2018

    @j-koenig
    Author

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

  7. jeffreyjackson commented on Apr 2, 2018

    @jeffreyjackson

    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

Metadata

Metadata

Assignees

Labels

type:bugImpaired feature or lacking behavior that is likely assumed

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions