Open
Description
- 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
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
Metadata
Metadata
Assignees
Labels
No labels
Activity
parse-community#7192 return validation error properly with beforeSave…
mtrezza commentedon Feb 15, 2021
Thanks for reporting.
Can you please add a code example to demonstrate the issue you are referring to?
sunshineo commentedon Feb 16, 2021
Not sure how to provide a code example to setup class with Date and beforeSave and post with invalid date. But anyone read my description should be able to reproduce on their server
dplewis commentedon Feb 20, 2021
How did you save an empty iso date?
mtrezza commentedon Feb 20, 2021
This may be related to (or be a duplicate of) #7087, but without a proper code example we'll have to close this issue due to lack of details. The PR is also missing the test case and I wasn't able to infer anything from the PR itself.
sunshineo commentedon Feb 22, 2021
I still have no time to learn the test system. So I spent half an hour to setup a project to demo the bug
https://github.com/sunshineo/parse-bug-demo
I hope the README.md is enough, but I can answer any questions
mtrezza commentedon Feb 22, 2021
@sunshineo Thanks, this is actually the "code example" that was needed:
It's still unclear to me why you are referring to two classes. What is the difference between class 1 and class 2? Wouldn't an empty or invalid iso date produce the same result in both classes?
sunshineo commentedon Feb 22, 2021
No, MyClass2 has a beforeSave trigger, and that makes it stuck
sunshineo commentedon Feb 22, 2021
mtrezza commentedon Feb 23, 2021
I was able to reproduce the error throwing instead of promise rejection in #7217.
@sunshineo The code example to describe this issue is as simple as this, no need to create a repo or learn the test system:
Feel free to take a look at the test case added in #7217, you will see it is not much more than the code above. The test system we use is jasmine, it is descriptive, easy to learn and there are many existing tests in Parse Server that usually make for a good blueprint.
Now that we have a failing test case, would you want to investigate the root cause and provide a fix?
sunshineo commentedon Feb 23, 2021
@mtrezza I have a fix. I have a pull request #7193
It's submitted before your test case. So is there a way to re-run the test and see if this fix make the test pass?
mtrezza commentedon Feb 23, 2021
You could simply add the test to your PR.
5 remaining items