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
- Create a class named
Stuff with a field named Owner of type Pointer and set the target class to User
- Deploy a
main.js file with a beforeSave for the Stuff class: Parse.Cloud.beforeSave('Stuff', (request) => {});
- 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
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)
New Issue Checklist
Issue Description
If a
beforeSaveis deployed for a certain class (even if it's just an empty function), trying to create a new object (POST) with a malformedPointer(objectIdis not present or is not aStringor is an empty string) produces a timeout.If the
beforeSaveis not there, even with a malformedPointer, the object is created correctly.Steps to reproduce
Stuffwith a field namedOwnerof typePointerand set the target class toUsermain.jsfile with abeforeSavefor theStuffclass:Parse.Cloud.beforeSave('Stuff', (request) => {});POSTwith a malformedPointerin theOwnerfield: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
Environment
Server
4.5.0unknownBack4AppDatabase
MongoDB3.6Back4AppClient
RESTunknownLogs