Skip to content

Error when passing null as Parse.Cloud.run option #2622

Closed
@modime

Description

@modime

New Issue Checklist

Issue Description

This bug was first found in https://github.com/parse-community/parse-server/ (see issue parse-community/parse-server#9766)

In _getRequestOptions in file ParseObject.js the parameter options is set to {} if it has no value. This works for values like '', undefined or if it is empty, but if it is null the code breaks.

Steps to reproduce

Call the function Parse.Cloud.run(<name>, data, null); or _ParseObject.default._getRequestOptions(null); directly.

Actual Outcome

Error:

TypeError: Cannot convert undefined or null to object
    at hasOwn (<anonymous>)
    at Function._getRequestOptions (/Users/#################/node_modules/parse/lib/node/ParseObject.js:423:9)
    at Object.run (/Users/#################/node_modules/parse/lib/node/Cloud.js:57:47)
…

Expected Outcome

When no options _getRequestOptions should return {}

Some kind of null check for the parameter options.

if(!options){
    return requestOptions;
}

Environment

I have tested this in 8.2.0 and 8.2.1-alpha.2. Error occurs in both.

The function does not exists in 7.5.2

Server

  • Parse Server version: 8.2.0
  • Operating system: macOS 15.5
  • Local or remote host (AWS, Azure, Google Cloud, Heroku, Digital Ocean, etc): local

Database

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

Client

  • SDK (iOS, Android, JavaScript, PHP, Unity, etc): Node
  • SDK version: 22.14.0

Client

  • Parse JS SDK version: 6.1.0

Metadata

Metadata

Assignees

No one assigned

    Labels

    type:bugImpaired feature or lacking behavior that is likely assumed

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions