Skip to content

Conversation

@mtrezza
Copy link
Member

@mtrezza mtrezza commented Nov 8, 2025

Pull Request

Issue

MongoStorageAdapter and GridFSBucketAdapter both pass the databaseOptions to the MongoDB client. The databaseOptions include both native MongoDB driver options and Parse Server custom options that need to be filtered out because the MongoDB client would reject them.

The list of options that must be filtered out before passing to MongoDB client is defined separately in MongoStorageAdapter and GridFSBucketAdapter. The list for GridFSBucketAdapter hasn't been updated in a while, so it passes a few options to the client that should be filtered out.

Approach

  • Dedupe the list of options to filter by defining a centralized list.
  • Side-fix: add missing Parse Server specific options to TS

Tasks

  • Add tests

Summary by CodeRabbit

  • Bug Fixes

    • Improved database option handling to reliably strip server-only options before connecting, preventing conflicts with the MongoDB client.
  • New Features

    • Added server configuration options for index and authentication behaviors: allowPublicExplain, disableIndexFieldValidation, logClientEvents, createIndexRoleName, createIndexUserEmail, createIndexUserEmailCaseInsensitive, createIndexUserEmailVerifyToken, createIndexUserPasswordResetToken, createIndexUserUsername, createIndexUserUsernameCaseInsensitive.

@parse-github-assistant
Copy link

parse-github-assistant bot commented Nov 8, 2025

🚀 Thanks for opening this pull request!

@coderabbitai
Copy link

coderabbitai bot commented Nov 8, 2025

📝 Walkthrough

Walkthrough

Replaces hard-coded Parse Server-specific MongoDB option removals with a shared exported ParseServerDatabaseOptions list; adapters copy and filter incoming mongoOptions using that list before passing to the MongoDB client; type defs updated to declare several Parse Server DB options; GridFS spec updated accordingly.

Changes

Cohort / File(s) Change Summary
Tests
spec/GridFSBucketStorageAdapter.spec.js
Updated test MongoDB connection options and comment to include additional Parse Server-specific options (allowPublicExplain, logClientEvents, createIndex* flags, disableIndexFieldValidation, etc.) that should be filtered before passing to the MongoDB client.
Defaults (new public constant)
src/defaults.js
Added and exported ParseServerDatabaseOptions — an array of Parse Server-specific database option names used to filter options before passing them to the MongoDB client.
Adapters — filtering logic
src/Adapters/Files/GridFSBucketAdapter.js, src/Adapters/Storage/Mongo/MongoStorageAdapter.js
Import ParseServerDatabaseOptions, shallow-copy incoming mongoOptions into this._mongoOptions, then iterate ParseServerDatabaseOptions to delete each server-only key from the copy before using it with the MongoDB client (removes hard-coded key list).
Type definitions
types/Options/index.d.ts
Added multiple Parse Server custom DB option declarations (allowPublicExplain, createIndexRoleName, createIndexUserEmail, createIndexUserEmailCaseInsensitive, createIndexUserEmailVerifyToken, createIndexUserPasswordResetToken, createIndexUserUsername, createIndexUserUsernameCaseInsensitive, disableIndexFieldValidation, logClientEvents) and moved maxTimeMS into the Parse Server custom options block; removed duplicate/driver-listed allowPublicExplain/maxTimeMS.

Sequence Diagram(s)

sequenceDiagram
    autonumber
    participant Caller as Adapter Init
    participant Adapter as Mongo/GridFS Adapter
    participant Defaults as src/defaults.js
    participant Mongo as MongoClient

    Caller->>Adapter: new Adapter(mongoOptions)
    Adapter->>Defaults: import ParseServerDatabaseOptions
    Adapter->>Adapter: this._mongoOptions = {...mongoOptions}  %% shallow copy
    Adapter->>Defaults: for each key in ParseServerDatabaseOptions
    Adapter->>Adapter: delete this._mongoOptions[key]  %% remove server-only keys
    Adapter->>Mongo: connect(this._mongoOptions)  %% pass filtered options
    Mongo-->>Adapter: connection established
    Adapter-->>Caller: adapter ready
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

  • Pay attention to:
    • Contents and completeness of ParseServerDatabaseOptions in src/defaults.js.
    • That adapters shallow-copy mongoOptions and do not mutate the original object.
    • Type definition changes for new Parse Server-specific options and correct placement of maxTimeMS.

Possibly related PRs

Suggested reviewers

  • Moumouls

Pre-merge checks and finishing touches

❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Description check ⚠️ Warning The description addresses the core issue and approach but is missing a critical required section: the Issue/Closes link to the GitHub issue that this PR resolves. Add a link to the GitHub issue that this PR closes in the 'Closes:' field, e.g., 'Closes: #XXXX'.
✅ Passed checks (2 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and accurately describes the main fix: GridFSBucketAdapter now properly handles Parse Server-specific options that should be filtered before passing to MongoDB client.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

📜 Recent review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between dc5bf00 and 99aa1f8.

📒 Files selected for processing (2)
  • src/defaults.js (1 hunks)
  • types/Options/index.d.ts (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (2)
  • src/defaults.js
  • types/Options/index.d.ts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🧹 Nitpick comments (1)
src/Adapters/Files/GridFSBucketAdapter.js (1)

40-56: LGTM! Consider alphabetical ordering for maintainability.

The expanded filtering correctly removes Parse Server-specific options before passing configuration to MongoClient.connect. The implementation matches the test coverage in GridFSBucketStorageAdapter.spec.js.

For improved maintainability, consider alphabetizing the options array:

-    for (const key of [
-      'allowPublicExplain',
-      'enableSchemaHooks',
-      'schemaCacheTtl',
-      'maxTimeMS',
-      'disableIndexFieldValidation',
-      'logClientEvents',
-      'createIndexUserUsername',
-      'createIndexUserUsernameCaseInsensitive',
-      'createIndexUserEmail',
-      'createIndexUserEmailCaseInsensitive',
-      'createIndexUserEmailVerifyToken',
-      'createIndexUserPasswordResetToken',
-      'createIndexRoleName',
-    ]) {
+    for (const key of [
+      'allowPublicExplain',
+      'createIndexRoleName',
+      'createIndexUserEmail',
+      'createIndexUserEmailCaseInsensitive',
+      'createIndexUserEmailVerifyToken',
+      'createIndexUserPasswordResetToken',
+      'createIndexUserUsername',
+      'createIndexUserUsernameCaseInsensitive',
+      'disableIndexFieldValidation',
+      'enableSchemaHooks',
+      'logClientEvents',
+      'maxTimeMS',
+      'schemaCacheTtl',
+    ]) {
       delete _mongoOptions[key];
     }
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 502a512 and e1802e0.

📒 Files selected for processing (3)
  • spec/GridFSBucketStorageAdapter.spec.js (1 hunks)
  • src/Adapters/Files/GridFSBucketAdapter.js (1 hunks)
  • types/Options/index.d.ts (1 hunks)
🧰 Additional context used
🧠 Learnings (3)
📓 Common learnings
Learnt from: mtrezza
Repo: parse-community/parse-server PR: 0
File: :0-0
Timestamp: 2025-11-08T13:46:04.917Z
Learning: When reviewing Parse Server PRs that add new features, always check whether the feature is documented in the README.md file, though for new Parse Server options this is optional rather than required.
Learnt from: mtrezza
Repo: parse-community/parse-server PR: 0
File: :0-0
Timestamp: 2025-11-08T13:46:04.917Z
Learning: For new Parse Server options, verify that the option is documented in src/Options/index.js and that npm run definitions has been executed to reflect changes in src/Options/docs.js and src/Options/Definitions.js. README.md documentation is a bonus but not required for new options.
Learnt from: EmpiDev
Repo: parse-community/parse-server PR: 9770
File: spec/CloudCode.spec.js:446-469
Timestamp: 2025-08-26T14:06:31.853Z
Learning: In the Parse Server codebase, when handling query objects in maybeRunAfterFindTrigger, objects without a where property that contain options like limit/skip should be treated as query JSON with an empty where clause using the spread pattern { where: {}, ...query }, not nested as { where: query }.
📚 Learning: 2025-11-08T13:46:04.917Z
Learnt from: mtrezza
Repo: parse-community/parse-server PR: 0
File: :0-0
Timestamp: 2025-11-08T13:46:04.917Z
Learning: For new Parse Server options, verify that the option is documented in src/Options/index.js and that npm run definitions has been executed to reflect changes in src/Options/docs.js and src/Options/Definitions.js. README.md documentation is a bonus but not required for new options.

Applied to files:

  • src/Adapters/Files/GridFSBucketAdapter.js
  • types/Options/index.d.ts
  • spec/GridFSBucketStorageAdapter.spec.js
📚 Learning: 2025-11-08T13:46:04.917Z
Learnt from: mtrezza
Repo: parse-community/parse-server PR: 0
File: :0-0
Timestamp: 2025-11-08T13:46:04.917Z
Learning: When reviewing Parse Server PRs that add new features, always check whether the feature is documented in the README.md file, though for new Parse Server options this is optional rather than required.

Applied to files:

  • spec/GridFSBucketStorageAdapter.spec.js
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (14)
  • GitHub Check: PostgreSQL 16, PostGIS 3.5
  • GitHub Check: PostgreSQL 18, PostGIS 3.6
  • GitHub Check: Node 22
  • GitHub Check: MongoDB 6, ReplicaSet
  • GitHub Check: PostgreSQL 17, PostGIS 3.5
  • GitHub Check: Node 20
  • GitHub Check: MongoDB 8, ReplicaSet
  • GitHub Check: MongoDB 7, ReplicaSet
  • GitHub Check: PostgreSQL 15, PostGIS 3.3
  • GitHub Check: PostgreSQL 15, PostGIS 3.4
  • GitHub Check: Node 18
  • GitHub Check: PostgreSQL 15, PostGIS 3.5
  • GitHub Check: Redis Cache
  • GitHub Check: Docker Build
🔇 Additional comments (1)
spec/GridFSBucketStorageAdapter.spec.js (1)

23-47: LGTM! Comprehensive test coverage for filtered options.

The test effectively verifies that:

  1. Parse Server-specific options can be passed to GridFSBucketAdapter without causing errors
  2. These options are filtered out before reaching the MongoDB client
  3. Valid MongoDB options (like retryWrites) are properly passed through to the database connection

The updated comment on line 27 clearly documents the purpose of these options.

@codecov
Copy link

codecov bot commented Nov 8, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 93.07%. Comparing base (4456b02) to head (99aa1f8).
⚠️ Report is 3 commits behind head on alpha.

Additional details and impacted files
@@           Coverage Diff           @@
##            alpha    #9915   +/-   ##
=======================================
  Coverage   93.07%   93.07%           
=======================================
  Files         187      187           
  Lines       15223    15224    +1     
  Branches      177      177           
=======================================
+ Hits        14169    14170    +1     
  Misses       1042     1042           
  Partials       12       12           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@mtrezza mtrezza merged commit d3d4003 into parse-community:alpha Nov 8, 2025
26 checks passed
parseplatformorg pushed a commit that referenced this pull request Nov 8, 2025
# [8.5.0-alpha.6](8.5.0-alpha.5...8.5.0-alpha.6) (2025-11-08)

### Bug Fixes

* `GridFSBucketAdapter` throws when using some Parse Server specific options in MongoDB database options ([#9915](#9915)) ([d3d4003](d3d4003))
@parseplatformorg
Copy link
Contributor

🎉 This change has been released in version 8.5.0-alpha.6

@parseplatformorg parseplatformorg added the state:released-alpha Released as alpha version label Nov 8, 2025
@mtrezza mtrezza deleted the fix/option-not-known branch November 8, 2025 17:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

state:released-alpha Released as alpha version

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants