Skip to content

Setting data to undefined using postgres causes parse server to crash #5065

Closed
@ben-eb

Description

@ben-eb

Issue Description

When updating an existing record, sending the value undefined will cause parse-server to crash, but when the value is null, it's OK.

I traced the problem down to these locations:

I would expect the simple fix would be to do this instead:

if (fieldValue === null || fieldValue === undefined) {
  // ...
}

Steps to reproduce

  1. Create a record with a value set.
  2. Save this record again with your value as undefined.

Expected Results

Parse should not throw an exception on undefined values.

Actual Outcome

Parse is throwing an exception when saving undefined values.

Environment Setup

  • Server

    • parse-server version (Be specific! Don't say 'latest'.) : 2.7.2 (although this exists in v3 also)
    • Operating System: Ubuntu (running via VM)
    • Hardware: 2017 MacBook Pro
    • Localhost or remote server? (AWS, Heroku, Azure, Digital Ocean, etc): VirtualBox environment.
  • Database

    • Version: 9.6.8
    • Storage engine: Postgres
    • Hardware: 2017 MacBook Pro
    • Localhost or remote server? (AWS, mLab, ObjectRocket, Digital Ocean, etc): VirtualBox environment.

Logs/Trace

App 8128 stderr: TypeError: Cannot read property '__op' of undefined
App 8128 stderr:     at PostgresStorageAdapter.updateObjectsByQuery (/var/www/app/current/node_modules/parse-server/lib/Adapters/Storage/Postgres/PostgresStorageAdapter.js:1104:29)
App 8128 stderr:     at PostgresStorageAdapter.findOneAndUpdate (/var/www/app/current/node_modules/parse-server/lib/Adapters/Storage/Postgres/PostgresStorageAdapter.js:1045:17)
App 8128 stderr:     at schemaController.getOneSchema.catch.then.schema (/var/www/app/current/node_modules/parse-server/lib/Controllers/DatabaseController.js:442:33)
App 8128 stderr:     at <anonymous>
App 8128 stderr:     at process._tickDomainCallback (internal/process/next_tick.js:228:7)

Is there any support still for the v2 releases? We're still relying on these for production instances - backporting a fix would be most welcomed.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions