parse-server
parse-server copied to clipboard
fix: invalid date in object causes unhandled promise rejection in beforeSave trigger
New Pull Request Checklist
- [x] I am not disclosing a vulnerability.
- [x] I am creating this PR in reference to an issue.
Issue Description
Related issue: https://github.com/parse-community/parse-server/issues/7192
Approach
TODOs before merging
- [x] Add test cases
- [x] Add entry to changelog
- [x] Add changes to documentation (guides, repository pages, in-code descriptions)
- [x] Add security check
- [x] Add new Parse Error codes to Parse JS SDK
Codecov Report
Merging #7193 (e0bfdcb) into alpha (20fc4e2) will increase coverage by
0.31%. The diff coverage is100.00%.
:exclamation: Current head e0bfdcb differs from pull request most recent head 4d9edb4. Consider uploading reports for the commit 4d9edb4 to get more accurate results
@@ Coverage Diff @@
## alpha #7193 +/- ##
==========================================
+ Coverage 93.82% 94.13% +0.31%
==========================================
Files 182 182
Lines 13629 13635 +6
==========================================
+ Hits 12787 12835 +48
+ Misses 842 800 -42
| Impacted Files | Coverage Δ | |
|---|---|---|
| src/triggers.js | 95.42% <100.00%> (+0.06%) |
:arrow_up: |
| src/RestWrite.js | 94.30% <0.00%> (-0.16%) |
:arrow_down: |
| src/Adapters/Cache/RedisCacheAdapter.js | 87.71% <0.00%> (+75.43%) |
:arrow_up: |
Continue to review full report at Codecov.
Legend - Click here to learn more
Δ = absolute <relative> (impact),ø = not affected,? = missing dataPowered by Codecov. Last update 8cf0b5e...4d9edb4. Read the comment docs.
Thanks for this PR. Can you please add a test case that covers the issue this PR intends to fix?
I don't know how to add a test case that setup beforeSave on a class with Date. Can someone provide some pointers?
Please look into the .spec.js files, there are test cases for saving an object as well as the beforeSave trigger. Combining both should yield the test case needed.
This would also be the code example that I asked for in the related issue.
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
Can you merge the latest commit of master?
From your comment:
I do not see any strong reason that we have to have 111 instead of 142. So I'll change the expected error message in the test and put it on my PR.
The error codes are not arbitrary, we have to pick the right one. As I commented in my PR, there may be an additional issue that we are getting two different error codes and messages for the same error.
@mtrezza Changelog added
Hello @mtrezza . I think I addressed everything. Let's merge it
@mtrezza Have a look now
Hello, can some one merge this? @mtrezza @ @dplewis @davimacedo
@sunshineo Can you please merge the current master into it to make the tests pass?
I just merged master into this branch.
@mtrezza @dplewis It's been a while, let's merge this. The change properly return error and fix the bug that hangs the whole server. The error code and message can be improved in the future if user feedback suggest it is confusing
@sunshineo Can you please update this branch with master and address any open review comments so we can merge this?
@mtrezza Merged master into the branch
Thanks, and could you
- address any open conversations in the reviews
- update the TODO list
@mtrezza done
⚠️ Important change for merging PRs from Parse Server 5.0 onwards!
We are planning to release the first beta version of Parse Server 5.0 in October 2021.
If a PR contains a breaking change and is not merged before the beta release of Parse Server 5.0, it cannot be merged until the end of 2022. Instead it has to follow the Deprecation Policy and phase-in breaking changes to be merged during the course of 2022.
One of the most voiced community feedbacks was the demand for predictability in breaking changes to make it easy to upgrade Parse Server. We have made a first step towards this by introducing the Deprecation Policy in February 2021 that assists to phase-in breaking changes, giving developers time to adapt. We will follow-up with the introduction of Release Automation and a branch model that will allow breaking changes only with a new major release, scheduled for the beginning of each calendar year.
We understand that some PRs are a long time in the making and we very much appreciate your contribution. We want to make it easy for PRs that contain a breaking change and were created before the introduction of the Deprecation Policy. These PRs can be merged with a breaking change without being phased-in before the beta release of Parse Server 5.0. We are making this exception because we appreciate that this is a time of transition that requires additional effort from contributors to adapt. We encourage everyone to prepare their PRs until the end of September and account for review time and possible adaptions.
If a PR contains a breaking change and should be merged before the beta release, please mention @parse-community/server-maintenance and we will coordinate with you to merge the PR.
Thanks for your contribution and support during this transition to Parse Server release automation!
I still seeing this in 5.0, whats going on looks like a simple fix... Is there a workaround I can do for now?
It seems the changes just need to be reviewed then we can release this as an alpha version.
Thanks for opening this pull request!
- 🎉 We are excited about your hands-on contribution!