-
-
Notifications
You must be signed in to change notification settings - Fork 4.8k
feat: Add option databaseOptions.clientMetadata to send custom metadata to database server for logging and debugging
#10017
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
Conversation
✅ Snyk checks have passed. No issues have been found so far.
💻 Catch issues earlier using the plugins for VS Code, JetBrains IDEs, Visual Studio, and Eclipse. |
Co-authored-by: mtrezza <5673677+mtrezza@users.noreply.github.com>
Co-authored-by: mtrezza <5673677+mtrezza@users.noreply.github.com>
Co-authored-by: mtrezza <5673677+mtrezza@users.noreply.github.com>
|
Important Review skippedBot user detected. To trigger a single review, invoke the You can disable this status message by setting the 📝 WalkthroughWalkthroughThis PR adds support for custom client metadata that can be passed to MongoDB driver connections. The feature introduces configuration options, environment variable mappings, adapter implementations to inject driver metadata, and test coverage to verify the metadata is properly transmitted to the MongoDB client. Changes
Sequence Diagram(s)sequenceDiagram
participant Config as Configuration / Environment
participant Parser as ParseServer Options Parser
participant Adapter as MongoStorageAdapter / GridFSBucketAdapter
participant MongoDrv as MongoDB Driver (MongoClient)
participant MongoSvr as MongoDB Server
Config->>Parser: PARSE_SERVER_CLIENT_METADATA env vars
Parser->>Adapter: ParseServerOptions with clientMetadata
Adapter->>Adapter: Store clientMetadata in _clientMetadata field
Adapter->>Adapter: Read _clientMetadata during _connect()
alt clientMetadata is provided
Adapter->>Adapter: Create driverInfo object {name, version}
Adapter->>Adapter: Inject driverInfo into MongoDB connection options
end
Adapter->>MongoDrv: connect() with options (potentially including driverInfo)
MongoDrv->>MongoSvr: Initial handshake with driver metadata
MongoSvr-->>MongoDrv: Connection established
MongoDrv-->>Adapter: Connection ready
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Possibly related PRs
🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. Comment |
|
🚀 Thanks for opening this pull request! |
mongoDBClientMetadata to send custom metadata to MongoDB
mongoDBClientMetadata to send custom metadata to MongoDBmongoDBClientMetadata to send custom metadata to MongoDB
mongoDBClientMetadata to send custom metadata to MongoDBmongoDBClientMetadata to send custom metadata to MongoDB server
|
@copilot rename the option to |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## alpha #10017 +/- ##
==========================================
- Coverage 92.54% 92.54% -0.01%
==========================================
Files 190 190
Lines 15468 15477 +9
Branches 176 176
==========================================
+ Hits 14315 14323 +8
- Misses 1141 1142 +1
Partials 12 12 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Co-authored-by: mtrezza <5673677+mtrezza@users.noreply.github.com>
mongoDBClientMetadata to send custom metadata to MongoDB serverdatabaseOptions.clientMetadata to send custom metadata to MongoDB server
|
@copilot fix the failing CI:
|
databaseOptions.clientMetadata to send custom metadata to MongoDB serverclientMetadata to send custom metadata to database server
Co-authored-by: mtrezza <5673677+mtrezza@users.noreply.github.com>
Fixed in commit 9c86062. Updated tests to check that |
|
@coderabbitai review |
✅ Actions performedReview triggered.
|
clientMetadata to send custom metadata to database serverdatabaseOptions.clientMetadata to send custom metadata to database server
databaseOptions.clientMetadata to send custom metadata to database serverdatabaseOptions.clientMetadata to send custom metadata to database server
databaseOptions.clientMetadata to send custom metadata to database serverdatabaseOptions.clientMetadata to send custom metadata to database server for logging and debugging
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.
Actionable comments posted: 0
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
resources/buildConfigDefinitions.js (1)
31-51: Fix the environment variable prefix forclientMetadatanested properties.The
ClientMetadatamapping inbuildConfigDefinitions.jsusesPARSE_SERVER_DATABASE_OPTIONS_CLIENT_METADATA_as the prefix, which is incorrect. SinceclientMetadatais a top-levelParseServerOptionsproperty (not nested underDatabaseOptions), the nested properties (name,version) should usePARSE_SERVER_CLIENT_METADATA_as the prefix instead.This causes the generated environment variables in
src/Options/Definitions.jsto bePARSE_SERVER_DATABASE_OPTIONS_CLIENT_METADATA_NAMEandPARSE_SERVER_DATABASE_OPTIONS_CLIENT_METADATA_VERSION, when they should bePARSE_SERVER_CLIENT_METADATA_NAMEandPARSE_SERVER_CLIENT_METADATA_VERSION.Update line 33 in
resources/buildConfigDefinitions.jsfrom:ClientMetadata: 'PARSE_SERVER_DATABASE_OPTIONS_CLIENT_METADATA_',to:
ClientMetadata: 'PARSE_SERVER_CLIENT_METADATA_',Then run
npm run definitionsto regeneratesrc/Options/Definitions.jsandsrc/Options/docs.jswith the correct prefixes.
# [9.2.0-alpha.1](9.1.1...9.2.0-alpha.1) (2026-01-24) ### Features * Add option `databaseOptions.clientMetadata` to send custom metadata to database server for logging and debugging ([#10017](#10017)) ([756c204](756c204))
|
🎉 This change has been released in version 9.2.0-alpha.1 |
Pull Request
Approach
Adds opt-in
clientMetadataoption to identify Parse Server instances in database logs during connection handshakes. Disabled by default to avoid data transfer overhead. The option is database-agnostic and can be used with MongoDB, Postgres, or other database adapters in the future.Note
The feature is explicitly implemented as opt-in. We believe it is in developers’ best interest for this to remain opt-in, mainly to not by default silently reveal metadata about a developer’s infrastructure or stack to a third party (e.g. a DBaaS provider). By definition, that weakens the security posture and violates the principle of explicit consent.
Implementation:
databaseOptions.clientMetadatadriverInfoto database client:{ name: <custom_metadata.name>, version: <custom_metadata.version> }MongoStorageAdapterandGridFSBucketAdapterto conditionally set metadataWithout this option, no metadata is sent (current behavior maintained).
Tasks
Summary by CodeRabbit
New Features
Tests
Chores
✏️ Tip: You can customize this high-level summary in your review settings.