Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

More specific error codes #7346

Closed
wants to merge 1 commit into from
Closed

Conversation

mstniy
Copy link
Contributor

@mstniy mstniy commented Apr 14, 2021

New Pull Request Checklist

  • [ x] I am not disclosing a vulnerability.
  • [ x] I am creating this PR in reference to an issue.

Issue Description

This PR makes certain error paths produce more specific error codes (e.g., INVALID_VALUE instead of INVALID_JSON, INVALID_JSON instead of INTERNAL_SERVER_ERROR)
It also fixes some unit tests, which previously did not test what they were meant to test.

Related issue: #7331

Approach

Error codes were made more specific where possible.
Geojson errors produced by Mongo are passed-through as Parse.Error.INVALID_VALUE, instead of causing INTERNAL_SERVER_ERROR.

TODOs before merging

  • [ x ] Add test cases
  • Add entry to changelog
  • Add changes to documentation (guides, repository pages, in-code descriptions)
  • Add security check
  • [ x ] Add new Parse Error codes to Parse JS SDK
  • Depend on a release of the js sdk, instead of a commit hash.

  Use the new INVALID_VALUE error code
Also fixed some unit tests
@mstniy
Copy link
Contributor Author

mstniy commented Apr 14, 2021

One thing I noticed is that the code uses INVALID_JSON pretty generously. It is supposed to be produced only when some input does not conform to the JSON syntax, but currently it is also used for several kinds of value/type errors. I do not have an immediate idea to fix that, nor is it within the scope of #7331, so many of them remain.
Changing the meaning of INVALID_JSON could be a simple fix.

@codecov
Copy link

codecov bot commented Apr 14, 2021

Codecov Report

Merging #7346 (aeb0f09) into master (87dcd23) will decrease coverage by 9.67%.
The diff coverage is 38.70%.

❗ Current head aeb0f09 differs from pull request most recent head 4cdeb81. Consider uploading reports for the commit 4cdeb81 to get more accurate results
Impacted file tree graph

@@            Coverage Diff             @@
##           master    #7346      +/-   ##
==========================================
- Coverage   93.89%   84.22%   -9.68%     
==========================================
  Files         181      181              
  Lines       13193    13207      +14     
==========================================
- Hits        12387    11123    -1264     
- Misses        806     2084    +1278     
Impacted Files Coverage Δ
...dapters/Storage/Postgres/PostgresStorageAdapter.js 2.46% <0.00%> (-92.91%) ⬇️
src/Routers/ClassesRouter.js 93.13% <0.00%> (-4.83%) ⬇️
src/Adapters/Storage/Mongo/MongoTransform.js 89.00% <88.88%> (+0.19%) ⬆️
src/Adapters/Storage/Mongo/MongoStorageAdapter.js 92.22% <100.00%> (-0.37%) ⬇️
src/Adapters/Cache/RedisCacheAdapter.js 12.28% <0.00%> (-75.44%) ⬇️
src/Adapters/Storage/Postgres/PostgresClient.js 5.00% <0.00%> (-65.00%) ⬇️
src/Controllers/UserController.js 95.34% <0.00%> (-2.33%) ⬇️
src/Controllers/FilesController.js 92.00% <0.00%> (-2.00%) ⬇️
src/batch.js 91.37% <0.00%> (-1.73%) ⬇️
... and 6 more

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 87dcd23...4cdeb81. Read the comment docs.

@mtrezza
Copy link
Member

mtrezza commented Apr 14, 2021

Thanks for this PR!

You mention that this PR is in relation to #7331, but the issue description sounds like it is generally improving the specificity of some error codes.

I would like to separate the changes that are essential to close #7331 from changes that are extraneous to that issue. The reason is that any change of error code is a potentially breaking change for existing deployments that rely on the current (albeit less specific) error code. We want to avoid unnecessary breaking changes and - if they are for cosmetic reasons - make them as part of a potential large one-time change, e.g. refining error codes on a broader basis.

@mstniy
Copy link
Contributor Author

mstniy commented Apr 14, 2021

Fair. I am closing this PR in favor of a smaller one.

@mstniy mstniy closed this Apr 14, 2021
@mtrezza
Copy link
Member

mtrezza commented Apr 14, 2021

Note: closed in favor of #7347.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants