parse-community / parse-community/parse-server

Invalid date iso with beforeSave make server unhandled promise rejection and request hanging

Open
#7,192 14 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

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

Description

Issue Description

Have a class with a column type Date. Try post with empty string as iso. Get proper error back

{
    "code": 111,
    "error": "This is not a valid Date"
}

Add beforeSave to the class and post again. Request will hang there forever. Server will fail with the following errors

(node:63110) UnhandledPromiseRejectionWarning: Error: Tried to encode an invalid date.
    at encode (/Users/gordon/workspace/pipe17/pipe17-group/parse/node_modules/parse/lib/node/encode.js:85:13)
    at _default (/Users/gordon/workspace/pipe17/pipe17-group/parse/node_modules/parse/lib/node/encode.js:132:10)
    at SetOp.toJSON (/Users/gordon/workspace/pipe17/pipe17-group/parse/node_modules/parse/lib/node/ParseOp.js:155:32)
    at ParseObject._getSaveJSON (/Users/gordon/workspace/pipe17/pipe17-group/parse/node_modules/parse/lib/node/ParseObject.js:485:61)
    at success (/Users/gordon/workspace/pipe17/pipe17-group/parse/node_modules/parse-server/lib/triggers.js:385:45)
    at processTicksAndRejections (internal/process/task_queues.js:93:5)
(Use `node --trace-warnings ...` to show where the warning was created)
  • 🤩 I will submit a PR with a fix (but probably need someone else do a proper fix)
Environment

Server

  • Parse Server version: 4.5.0

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

Start with the beforeSave trigger flow in parse-server/lib/triggers.js and the error path shown in the Parse encode stack trace. Reproduce a Date field submitted with an empty ISO string, both with and without beforeSave; done means the request returns a proper error without hanging or producing an unhandled promise rejection.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, nodejs
Domain
api, backend
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.