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
feat: Prevent Parse Server start in case of unknown option in server configuration #8987
Conversation
Thanks for opening this pull request! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you please separate the test into distinct tests, each with their own specific description, for example these scenarios:
a) no warning logged if no unknown option is set
b) warning logged if unknown option is set on root { unknown: 1 }
c) ... on sub object { a: { unknown: 1 }}
d) 2 warnings logged on 2 invalid options
Could you also please rename the warning msg to:
“The following Parse Server option is not recognized”, instead of “key”.
Also, I believe the server shouldn’t even start up if an invalid option has been set, because it is likely configured incorrectly, which could affect data integrity, security, app performance or user experience.
Hello @mtrezza, For tests, the given test includes these 3 conditions that you mentioned. Is there something else that you want me to do in that respect? |
Yes, could you please refactor the test into individual tests, one for reach scenario? The purpose of a test is to test a specific scenario that is described in the test title. So that it's easier to debug if a specific test fails, than a composite test that contains many smaller tests. The repetitive code can be moved into the |
Hi @mtrezza, Before I was checking for config variables based on the keys of defnitions from Definitions.js, but now I realize that there are several other keys that are being used that are not mentioned in those defnitions: level, loggerController, filesController, userController, pushController, pushWorker, .... |
Not sure, I think all these options should be somewhere in the code; but I'm not sure if there is a comprehensive list of all options. Maybe the definitions file of the Parse Server options is the best source for that? |
The definitions files doesn't give most of the variables. |
I believe we need a solution that doesn't require maintaining a separate list if we already have a list, like the definitions. What is missing in the definitions file, for example? |
state, loggerController, hasPushScheduledSupport, authDataManager, masterKeyIpsStore, maintenanceKeyIpsStore to name some. |
Are these really Parse Server options? I mean the main issue is, if they are not in the definitions file, then they are not (poorly) documented Parse Server options, because the docs for them is auto generated from the definitions file. If they are really undocumented then I suggest to add them to the definitions file, which is fairly easy to do. You could take a look at the existing options and then just add them. There are instructions on how to do that here. |
Yes, I understand but at one point or another they are expected in the config variable. They are also used in test files as well which is causing a lot of log messages during tests. |
Yes, so I believe the definitions file is the actual source to determine whether an option key is valid or not. If an options is missing there then that's likely a bug and we could simply add it, as part of this feature. I assume they are not many? |
I ran tests, some of them didn't pass, but I got warning messages for these keys: cacheController, loggerController, filesController, 3, masterKeyIpsStore, pushController, exampleKey, rateLimits, 5, userController, state, hasPushScheduledSupport, version, _mount, retryWrites, 4, databaseController, authDataManager, parseGraphQLController, schemaCache, RateLimitZone, 0, liveQueryController, database, generateEmailVerifyTokenExpiresAt, generateSessionExpiresAt, analyticsController, maintenanceKeyIpsStore, patternValidator, 2, hooksController, SchemaCacheTtl, level, hasPushSupport, pushWorker, applicationId, 1, pushControllerQueue |
The items |
Sorry for late reply. You were right there was a slight mistake that numbers were getting printed. But I looked into other keys and the locations they are set: _mount and some others keys. |
Yes, so whatever is missing and is really a Parse Server option may need to to be added to the definitions file. That's easy, see the link I shared previously. I doubt that |
…nfig variables | fixed issues with initial validations
Hey @mtrezza, I'm done with this one. Please review and let me know if something else needs to be changed. |
Could you resolve the conflicts? |
99a03d2
to
37e3934
Compare
@mtrezza, Conflicts resolved. |
You mean to the /src/Options/index.js file? Could you give an example how that would look like? |
not the index.js file but the Definitions file that is created finally. For example in /src/Options/index.js file In the definitions files it will come out as: |
Got it, I assume you would parse the type in
Even if you ignore any types that have non-letter chars, you would still end up with I see there is a |
Yes that is what I was suggesting as well. SO is it all right then? So I go ahead with this? |
Yes, sounds good! |
14ac915
to
eec9dee
Compare
eec9dee
to
5756cca
Compare
Signed-off-by: Manuel <5673677+mtrezza@users.noreply.github.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Very nice! This looks much cleaner now. Let's wait for the CI to pass, then this is good to merge?
yes it is done from my end. |
# [7.1.0-alpha.5](7.1.0-alpha.4...7.1.0-alpha.5) (2024-04-07) ### Features * Prevent Parse Server start in case of unknown option in server configuration ([#8987](#8987)) ([8758e6a](8758e6a))
🎉 This change has been released in version 7.1.0-alpha.5 |
Pull Request
Issue
Closes: #8938
Approach
Created a simple function that checks provided configuration keys against a list of possible keys (retrieved from the definitions file at src/Options/Definition.js). If any provided key is not valid, the function logs a warning message.