Skip to content

Parse *times out* if invalid Pointer is sent with a beforeSave trigger in place #7490

Description

@kashlyn39

New Issue Checklist

Issue Description

If a beforeSave is deployed for a certain class (even if it's just an empty function), trying to create a new object (POST) with a malformed Pointer (objectId is not present or is not a String or is an empty string) produces a timeout.

If the beforeSave is not there, even with a malformed Pointer, the object is created correctly.

Steps to reproduce

  1. Create a class named Stuff with a field named Owner of type Pointer and set the target class to User
  2. Deploy a main.js file with a beforeSave for the Stuff class: Parse.Cloud.beforeSave('Stuff', (request) => {});
  3. Try to POST with a malformed Pointer in the Owner field:
curl 'https://YOUR.PARSE-SERVER.HERE/parse/classes/Stuff' 
-H 'X-Parse-Application-Id: <App-ID>' 
-H 'X-Parse-Client-Key: <Client-Key>' 
--data-raw '{"Owner":{"__type":"Pointer","className":"_User","obejctId":""}}'

* note that in this request objectId is an empty string

Actual Outcome

No response, eventually times out.

Expected Outcome

Successful creation of the new object, as it does without the beforeSave:
{"objectId":"22IlcgdXQO","createdAt":"2021-08-14T22:25:33.899Z"}

Failing Test Case / Pull Request

  • 🤩 I submitted a PR with a fix and a test case.
  • 🧐 I submitted a PR with a failing test case.

Environment

Server

  • Parse Server version: 4.5.0
  • Operating system: unknown
  • Local or remote host (AWS, Azure, Google Cloud, Heroku, Digital Ocean, etc): Back4App

Database

  • System (MongoDB or Postgres): MongoDB
  • Database version: 3.6
  • Local or remote host (MongoDB Atlas, mLab, AWS, Azure, Google Cloud, etc): Back4App

Client

  • SDK (iOS, Android, JavaScript, PHP, Unity, etc): REST
  • SDK version: unknown

Logs

2021-08-14T22:57:59.757Z -
(node:18) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 5)
2021-08-14T22:57:59.756Z -
(node:18) UnhandledPromiseRejectionWarning: Error: Cannot create a pointer to an unsaved ParseObject
    at ParseUser.toPointer (/usr/src/app/node_modules/parse-server/node_modules/parse/lib/node/ParseObject.js:813:13)
    at encode (/usr/src/app/node_modules/parse-server/node_modules/parse/lib/node/encode.js:64:20)
    at _default (/usr/src/app/node_modules/parse-server/node_modules/parse/lib/node/encode.js:132:10)
    at SetOp.toJSON (/usr/src/app/node_modules/parse-server/node_modules/parse/lib/node/ParseOp.js:155:32)
    at ParseObject._getSaveJSON (/usr/src/app/node_modules/parse-server/node_modules/parse/lib/node/ParseObject.js:490:37)
    at success (/usr/src/app/node_modules/parse-server/lib/triggers.js:385:45)
    at processTicksAndRejections (internal/process/task_queues.js:93:5)

Metadata

Metadata

Assignees

No one assigned

    Labels

    type:bugImpaired feature or lacking behavior that is likely assumed

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions