parse-server icon indicating copy to clipboard operation
parse-server copied to clipboard

fix: invalid date in object causes unhandled promise rejection in beforeSave trigger

Open sunshineo opened this issue 4 years ago • 22 comments
trafficstars

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

sunshineo avatar Feb 15 '21 22:02 sunshineo

Codecov Report

Merging #7193 (e0bfdcb) into alpha (20fc4e2) will increase coverage by 0.31%. The diff coverage is 100.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 data Powered by Codecov. Last update 8cf0b5e...4d9edb4. Read the comment docs.

codecov[bot] avatar Feb 15 '21 22:02 codecov[bot]

Thanks for this PR. Can you please add a test case that covers the issue this PR intends to fix?

mtrezza avatar Feb 15 '21 22:02 mtrezza

I don't know how to add a test case that setup beforeSave on a class with Date. Can someone provide some pointers?

sunshineo avatar Feb 16 '21 18:02 sunshineo

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.

mtrezza avatar Feb 16 '21 19:02 mtrezza

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

sunshineo avatar Feb 22 '21 21:02 sunshineo

Can you merge the latest commit of master?

mtrezza avatar Feb 23 '21 19:02 mtrezza

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 avatar Feb 23 '21 19:02 mtrezza

@mtrezza Changelog added

sunshineo avatar Mar 10 '21 18:03 sunshineo

Hello @mtrezza . I think I addressed everything. Let's merge it

sunshineo avatar Mar 13 '21 01:03 sunshineo

@mtrezza Have a look now

sunshineo avatar Mar 17 '21 23:03 sunshineo

Hello, can some one merge this? @mtrezza @ @dplewis @davimacedo

sunshineo avatar Mar 30 '21 22:03 sunshineo

@sunshineo Can you please merge the current master into it to make the tests pass?

mtrezza avatar Mar 30 '21 22:03 mtrezza

I just merged master into this branch.

sunshineo avatar Mar 30 '21 23:03 sunshineo

@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 avatar Jun 30 '21 20:06 sunshineo

@sunshineo Can you please update this branch with master and address any open review comments so we can merge this?

mtrezza avatar Jul 26 '21 18:07 mtrezza

@mtrezza Merged master into the branch

sunshineo avatar Aug 04 '21 06:08 sunshineo

Thanks, and could you

  • address any open conversations in the reviews
  • update the TODO list

mtrezza avatar Aug 15 '21 10:08 mtrezza

@mtrezza done

sunshineo avatar Aug 16 '21 17:08 sunshineo

⚠️ 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!

mtrezza avatar Sep 03 '21 00:09 mtrezza

I still seeing this in 5.0, whats going on looks like a simple fix... Is there a workaround I can do for now?

zanderisrael avatar Apr 27 '22 11:04 zanderisrael

It seems the changes just need to be reviewed then we can release this as an alpha version.

mtrezza avatar Apr 27 '22 11:04 mtrezza

Thanks for opening this pull request!

  • 🎉 We are excited about your hands-on contribution!