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

New: Validate Cloud Validators #7154

Merged
merged 19 commits into from
Mar 1, 2021

Conversation

dblythy
Copy link
Member

@dblythy dblythy commented Jan 31, 2021

New Pull Request Checklist

Issue Description

Adds a cloud validator validator to make sure that cloud validators are formatted correctly.

Related issue: #7153

Approach

Validates when a new trigger is created.

TODOs before merging

  • Add test cases
  • Add entry to changelog

@codecov
Copy link

codecov bot commented Jan 31, 2021

Codecov Report

Merging #7154 (f404248) into master (c4aadc9) will decrease coverage by 0.00%.
The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #7154      +/-   ##
==========================================
- Coverage   94.03%   94.03%   -0.01%     
==========================================
  Files         172      172              
  Lines       12913    12959      +46     
==========================================
+ Hits        12143    12186      +43     
- Misses        770      773       +3     
Impacted Files Coverage Δ
src/cloud-code/Parse.Cloud.js 99.20% <100.00%> (+0.46%) ⬆️
src/batch.js 91.37% <0.00%> (-1.73%) ⬇️
src/ParseServerRESTController.js 97.01% <0.00%> (-1.50%) ⬇️
src/Adapters/Files/GridFSBucketAdapter.js 79.50% <0.00%> (-0.82%) ⬇️

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 c4aadc9...b210b38. Read the comment docs.

@dblythy dblythy closed this Feb 1, 2021
@dblythy dblythy reopened this Feb 1, 2021
Copy link
Member

@davimacedo davimacedo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you think it would be possible to also add at least one test case to make sure that nothing logs in when the configuration is valid?

@dblythy
Copy link
Member Author

dblythy commented Feb 9, 2021

Good call, added in

Copy link
Member

@davimacedo davimacedo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@dblythy dblythy marked this pull request as draft February 21, 2021 06:21
@dblythy
Copy link
Member Author

dblythy commented Feb 21, 2021

Needs to include new validator options requireAllRoles requireAnyRoles

@dblythy dblythy marked this pull request as ready for review February 21, 2021 14:00
CHANGELOG.md Outdated Show resolved Hide resolved
@mtrezza
Copy link
Member

mtrezza commented Feb 23, 2021

Why is a failed validation only logging an error (that can be easily overseen) and not throwing an error on server start? I assume that in usual cases, validation configuration is not dynamically defined but statically defined once on server start when Cloud Functions are loaded. So if this fails once, it will always fail, thus it can be predicted to fail, thus it could tell the developer at server start already that there is a misconfiguration.

Given its expected use as security / access rights related feature, preventing to start the server seems more appropriate than just logging an error. We also don't just log but throw an error if a Parse Server option is incorrect, for example.

That's another reason why I suggested that this PR should ideally use a generic validation logic, for unified incorrect config handling across Parse Server. Otherwise this gets increasingly confusing for developers, sometimes logging, sometimes throwing, sometimes silently failing gracefully.

@mtrezza
Copy link
Member

mtrezza commented Feb 23, 2021

Well, thanks for reacting so fast in changing to throwing, but I actually wanted to start a discussion about it to find a solution. What's your opinion on that?

@dblythy
Copy link
Member Author

dblythy commented Feb 23, 2021

Sorry @mtrezza I’d thought that I’d replied to you.

I didn’t realise that you meant a class to validate the Parse Server options as well. I think that’s a good idea and will make it a lot easier to add new features. I’d be happy to work on that in this PR if that’s the course you’d like to take.

I think throwing the error makes sense. The only concern is that it might break some configurations if they’ve accidentally mistyped a field.

@mtrezza
Copy link
Member

mtrezza commented Feb 23, 2021

I agree that a generic config validation doesn't have to be in this PR.

The only concern is that it might break some configurations if they’ve accidentally mistyped a field.

Isn't mistyping one of the reasons why we'd want to throw? Can you give an example?

@dblythy
Copy link
Member Author

dblythy commented Feb 24, 2021

I mean that I would break existing configurations that currently have a mistyped key. It would effectively be a “breaking change”.

@mtrezza
Copy link
Member

mtrezza commented Feb 24, 2021

Introducing validation is not a breaking change as we do not assume misconfiguration as the basis reference to determine what constitutes a breaking change.

In other words, a misconfiguration is a developer bug, to which the same considerations apply as to a repository bug, which is also not assumed to be a basis reference. Quite the contrary, especially security related bugs (by developer or repo) should be revealed as prominently as possible to fix them quickly.

@mtrezza
Copy link
Member

mtrezza commented Mar 1, 2021

@dblythy Would you merge current master to get the tests to pass?

@mtrezza
Copy link
Member

mtrezza commented Mar 1, 2021

@dblythy Do you think this PR is ready, or anything you want to add?

Copy link
Member

@mtrezza mtrezza left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@dblythy
Copy link
Member Author

dblythy commented Mar 1, 2021

@dblythy Do you think this PR is ready, or anything you want to add?

I'm happy with it, thanks Manuel 😊

@mtrezza mtrezza merged commit 3833868 into parse-community:master Mar 1, 2021
@mtrezza
Copy link
Member

mtrezza commented Mar 1, 2021

Great!

@dblythy dblythy deleted the validateValidator branch March 1, 2021 23:56
@parseplatformorg
Copy link
Contributor

🎉 This change has been released in version 5.0.0-beta.1

@parseplatformorg parseplatformorg added the state:released-beta Released as beta version label Nov 1, 2021
@mtrezza mtrezza mentioned this pull request Mar 12, 2022
@parseplatformorg
Copy link
Contributor

🎉 This change has been released in version 5.0.0

@parseplatformorg parseplatformorg added the state:released Released as stable version label Mar 14, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
state:released Released as stable version state:released-beta Released as beta version
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants