parse-community / parse-community/parse-server

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

Open
#7,490 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

type:bug
Dominant language
JavaScript
Stars
21.4k
Forks
4.8k
Avg merge
7h 45m
Merged PRs (30d)
11

Description

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)

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.