-
Notifications
You must be signed in to change notification settings - Fork 5.3k
MongoDB - update to new-document source #16820
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
base: master
Are you sure you want to change the base?
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎ 3 Skipped Deployments
|
""" WalkthroughThe changes introduce support for integer-based timestamp fields in the MongoDB "New Document" trigger component. A new property allows users to specify the timestamp field type, and the logic for extracting and querying timestamps is updated accordingly. The package version is incremented to reflect these enhancements. Changes
Sequence Diagram(s)sequenceDiagram
participant User
participant MongoDBTrigger
participant MongoDB
User->>MongoDBTrigger: Configure trigger (choose timestampFieldType)
MongoDBTrigger->>MongoDB: Query for new documents using timestampField and type
MongoDB-->>MongoDBTrigger: Return matching documents
MongoDBTrigger->>User: Emit new document events
Assessment against linked issues
Possibly related PRs
Poem
Warning There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure. 🔧 ESLint
components/mongodb/sources/new-document/new-document.mjsOops! Something went wrong! :( ESLint: 8.57.1 Error [ERR_MODULE_NOT_FOUND]: Cannot find package 'jsonc-eslint-parser' imported from /eslint.config.mjs Note ⚡️ AI Code Reviews for VS Code, Cursor, WindsurfCodeRabbit now has a plugin for VS Code, Cursor and Windsurf. This brings AI code reviews directly in the code editor. Each commit is reviewed immediately, finding bugs before the PR is raised. Seamless context handoff to your AI code agent ensures that you can easily incorporate review feedback. 📜 Recent review detailsConfiguration used: CodeRabbit UI 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
⏰ Context from checks skipped due to timeout of 90000ms (3)
✨ Finishing Touches
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. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
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: 1
🧹 Nitpick comments (1)
components/mongodb/sources/new-document/new-document.mjs (1)
59-72
: Consider adding type validation for the selected timestamp field type.While the logic correctly handles both timestamp types, there's no validation to ensure the actual field values match the selected
timestampFieldType
. This could lead to runtime errors if users misconfigure the field type.Consider adding validation in the
getTs
method:getTs(doc) { const tsValue = doc[this.timestampField]; if (this.timestampFieldType === "Integer") { + if (typeof tsValue !== "number" && !Number.isInteger(Number(tsValue))) { + console.warn(`Expected integer timestamp but got ${typeof tsValue}: ${tsValue}`); + } return tsValue; } // ... rest of the method }
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
⛔ Files ignored due to path filters (1)
pnpm-lock.yaml
is excluded by!**/pnpm-lock.yaml
📒 Files selected for processing (2)
components/mongodb/package.json
(1 hunks)components/mongodb/sources/new-document/new-document.mjs
(4 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (4)
- GitHub Check: Verify TypeScript components
- GitHub Check: pnpm publish
- GitHub Check: Publish TypeScript components
- GitHub Check: Lint Code Base
🔇 Additional comments (5)
components/mongodb/package.json (1)
3-3
: LGTM! Appropriate version bump for new functionality.The version increment from 0.1.2 to 0.1.3 correctly reflects the addition of integer timestamp field support in the new-document source.
components/mongodb/sources/new-document/new-document.mjs (4)
9-9
: LGTM! Component version bump aligns with package version.The version increment is consistent with the package.json changes and reflects the new integer timestamp support.
32-33
: Good update to reflect expanded timestamp type support.Removing the Timestamp type requirement from the description accurately reflects that the field now supports both Timestamp and Integer types.
61-63
: LGTM! Clean implementation for integer timestamp handling.The early return for integer types correctly bypasses the string/JSON parsing logic and returns the raw integer value as expected.
92-94
:❓ Verification inconclusive
Verify query compatibility with MongoDB integer comparisons.
The conditional query logic correctly handles both timestamp types, but ensure that MongoDB can properly compare integer values in the
$gt
operation whentimestampFieldType
is "Integer".Run the following script to verify MongoDB integer comparison behavior:
🏁 Script executed:
#!/bin/bash # Description: Search for MongoDB query patterns and integer comparison usage # Expected: Find examples of integer field comparisons in MongoDB queries # Search for similar MongoDB query patterns with integer comparisons rg -A 5 -B 5 '\$gt.*[0-9]+' --type jsLength of output: 39
Confirm BSON integer comparisons in
$gt
queryWe didn’t find any existing examples of numeric
$gt
comparisons in the codebase. WhentimestampFieldType === "Integer"
, make sure thatlastTs
is sent as a BSON integer (e.g.Int32
orLong
) rather than the default BSON double—otherwise your integer‐typed timestamp field may not compare as expected.• File: components/mongodb/sources/new-document/new-document.mjs
Lines 92–94:$gt: this.timestampFieldType === "Integer" ? lastTs // ensure this is wrapped as Int32/Long : this.convertToTimestamp(lastTs),
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.
Hi @michelle0927 lgtm! Ready for QA!
Resolves #16805
It looks like it's only not emitting events if the "Timestamp Field" entered isn't of type Timestamp, so I added the option to use a timestamp field of type Integer.
Summary by CodeRabbit