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

MongoDB option keys incorrectly identified as invalid #9211

Closed
mtrezza opened this issue Jul 17, 2024 · 4 comments · Fixed by #9213
Closed

MongoDB option keys incorrectly identified as invalid #9211

mtrezza opened this issue Jul 17, 2024 · 4 comments · Fixed by #9213
Labels
state:released Released as stable version state:released-alpha Released as alpha version state:released-beta Released as beta version type:bug Impaired feature or lacking behavior that is likely assumed

Comments

@mtrezza
Copy link
Member

mtrezza commented Jul 17, 2024

New Issue Checklist

Issue Description

#8987 introduced a feature that prevents Parse Server to start when an invalid option is identified. This was to prevent a misconfigured Parse Server to be deployed and potentially be insecure or for example cause damage to data integrity.

This currently incorrectly identifies some nested keys of databaseOptions as invalid keys. Some of the nested keys are directly passed to the MongoDB driver without being validated by Parse Server, as to allow developers to customize the MongoDB driver using its low-level options, for example:

  • maxStalenessSeconds
  • maxPoolSize

Other nested keys are parsed by Parse Server, for example:

  • maxTimeMS

Other nested keys are used for Parse Server's internal configuration and not passed to the MongoDB driver, for example:

  • enableSchemaHooks

In short, as long as databaseOptions is a potpourri of key types, its keys cannot be reasonably validated for correctness. There are various possible solutions to this; the easiest ones:

  • a) Disable validation for nested keys of databaseOptions; con: disables validation for parts of the Parse Server config.
  • b) Add missing keys to config definition so that they are recognized as valid; con: requires regular updates on Parse Server if MongoDB driver introduces new options, even though they may be irrelevant for Parse Server; Parser Server assumes the role of validating MongoDB driver options.
  • c) Introduce a dedicated unsafeDriverOptions key whose nested keys are "unsafe", i.e. not validated and passed directly to the DB driver. Con: not practical as the MongoDB driver is a Parse Server dependency that can change at any time and may break "unsafe" driver options set in the Server config.

(b) looks like the correct approach, since the options are set via the Parse Server config and because (c) is too unstable.

Steps to reproduce

Start Parse Server with config:

const config = {
  ...,
  databaseOptions: {
    maxTimeMS: 1000,
    maxStalenessSeconds: 10,
    maxPoolSize: 10,
  }
}

Actual Outcome

Error logged:

error: Invalid Option Keys Found: databaseOptions.maxTimeMS, databaseOptions.maxStalenessSeconds, databaseOptions.maxPoolSize

Expected Outcome

No error logged, as these are all valid keys.

Environment

Server

  • Parse Server version: 7.2.0
Copy link

parse-github-assistant bot commented Jul 17, 2024

Thanks for opening this issue!

  • 🚀 You can help us to fix this issue faster by opening a pull request with a failing test. See our Contribution Guide for how to make a pull request, or read our New Contributor's Guide if this is your first time contributing.

@mtrezza mtrezza added the type:bug Impaired feature or lacking behavior that is likely assumed label Jul 17, 2024
@parseplatformorg
Copy link
Contributor

🎉 This change has been released in version 7.3.0-alpha.2

@parseplatformorg parseplatformorg added the state:released-alpha Released as alpha version label Jul 17, 2024
@parseplatformorg
Copy link
Contributor

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

@parseplatformorg parseplatformorg added the state:released-beta Released as beta version label Oct 3, 2024
@parseplatformorg
Copy link
Contributor

🎉 This change has been released in version 7.3.0

@parseplatformorg parseplatformorg added the state:released Released as stable version label Oct 3, 2024
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-alpha Released as alpha version state:released-beta Released as beta version type:bug Impaired feature or lacking behavior that is likely assumed
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants