parse-community / parse-community/parse-server
Parse *times out* if invalid Pointer is sent with a beforeSave trigger in place
Nobody has claimed this yet.
- Dominant language
- JavaScript
- Stars
- 21.4k
- Forks
- 4.8k
- Avg merge
- 7h 45m
- Merged PRs (30d)
- 11
Description
New Issue Checklist
- I am not disclosing a vulnerability.
- I am not just asking a question.
- I have searched through existing issues.
- I can reproduce the issue with the latest version of Parse Server.
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
Stuffwith a field namedOwnerof typePointerand set the target class toUser - Deploy a
main.jsfile with abeforeSavefor theStuffclass:Parse.Cloud.beforeSave('Stuff', (request) => {}); - Try to
POSTwith a malformedPointerin theOwnerfield:
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
objectIdis 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)
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Reproduce the POST described in the issue with a beforeSave trigger and malformed Pointer, then inspect the success path in lib/triggers.js, especially the area shown in the stack trace. The issue is resolved when this request no longer times out or produces an unhandled rejection and matches the successful creation behavior without the trigger.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript, node.js
- Domain
- api, backend
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 42/100