parse-community / parse-server

Parse Server for Node.js / Express
https://parseplatform.org
Apache License 2.0
20.7k stars 4.76k forks source link

Multiple Validation failures causes server crash #8826

Open alino20 opened 7 months ago

alino20 commented 7 months ago

New Issue Checklist

Issue Description

I have multiple fields to validate before saving an object. But in certain conditions, This causes server to crash

Steps to reproduce

Cloud Code:

Parse.Cloud.beforeSave('JobList', async (request) => {}, {
  fields: {
    type: {
      required: true,
      type: String,
      options: ['Option A', 'Option B'],
    },
    project: {required: true},
  },
  validateMasterKey: true,
});

Field project is a pointer to another class.

send a save request with empty project field and an invalid string for type field (Anything other than "Option A" or "Option B").

Actual Outcome

The client receives the response Validation failed. Please specify data for project. but also server crashes!

Expected Outcome

The response can have either one of validation failed messages. but server should not crash.

Environment

Server

Database

Client

Logs

Server writes the following error message in console:

[UnhandledPromiseRejection: 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(). The promise rejected with the reason "Validation failed. Invalid option for type. Expected: Option A, Option B".] {
  code: 'ERR_UNHANDLED_REJECTION'
}
parse-github-assistant[bot] commented 7 months ago

Thanks for opening this issue!

NabilPopo commented 2 weeks ago

This issue still produce when even I try to verify inputs and I send empty field it will crash the server

mtrezza commented 2 weeks ago

Could someone please open a PR with a failing test that demonstrates the issue?

NabilPopo commented 2 weeks ago

I will do it