-
Notifications
You must be signed in to change notification settings - Fork 27
build(deps): bump mongodb from 6.20.0 to 7.0.0 #2192
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: main
Are you sure you want to change the base?
Conversation
Bumps [mongodb](https://github.com/mongodb/node-mongodb-native) from 6.20.0 to 7.0.0. - [Release notes](https://github.com/mongodb/node-mongodb-native/releases) - [Changelog](https://github.com/mongodb/node-mongodb-native/blob/main/HISTORY.md) - [Commits](mongodb/node-mongodb-native@v6.20.0...v7.0.0) --- updated-dependencies: - dependency-name: mongodb dependency-version: 7.0.0 dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] <[email protected]>
abe4d4d to
45c2f48
Compare
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.
Pull Request Overview
This PR upgrades the MongoDB Node.js driver from version 6.20.0 to 7.0.0, a major version update that includes breaking changes and requires Node.js >= 20.19.0. The upgrade necessitated updates to the device update logic to handle ObjectId conversion properly.
Key Changes:
- Upgraded
mongodbpackage from 6.20.0 to 7.0.0 with corresponding dependency updates (bson,mongodb-connection-string-url,@types/whatwg-url) - Added ObjectId validation and conversion logic in the device update method
- Reformatted code in device routes for improved readability
- Applied formatting improvements to swagger.yaml
Reviewed Changes
Copilot reviewed 4 out of 5 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| package.json | Upgraded mongodb dependency to version 7.0.0 |
| package-lock.json | Updated lockfile with MongoDB 7.0.0 and related dependency versions including bson 7.0.0 and updated peer dependency versions |
| src/data/mongo/collections/device.ts | Added validation for _id field and ObjectId conversion logic with support for both valid ObjectId strings and numeric IDs |
| src/routes/devices/index.ts | Reformatted redirectstatus route definition for better readability |
| swagger.yaml | Applied consistent formatting and whitespace cleanup throughout the API documentation |
Comments suppressed due to low confidence (1)
src/data/mongo/collections/device.ts:78
- The
findOneAndUpdatecall may returnnullif no document is found matching the filter criteria, but the method doesn't handle this case before returningresult as any. This will cause the method to returnnullwhen a device with the given_idandtenantIddoesn't exist, potentially leading to null reference errors in calling code.
Consider adding a null check:
if (!result) {
throw new Error(`Device not found with _id: ${objectId}`)
}
return result as any const result = await this.collection.findOneAndUpdate(
{ _id: objectId, tenantId: item.tenantId },
{ $set: item },
{ returnDocument: 'after', includeResultMetadata: false }
)
return result as any
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| } else if (typeof itemId === 'number') { | ||
| objectId = new ObjectId(itemId.toString().padStart(24, '0')) | ||
| } else { | ||
| throw new Error(`Invalid _id format: ${itemId}`) |
Copilot
AI
Nov 11, 2025
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.
Converting a number to an ObjectId by padding with zeros is fragile and could lead to unexpected behavior. This assumes numeric IDs are always less than 24 characters when stringified and that padding them to create a valid ObjectId hex string is meaningful.
Consider one of these approaches instead:
- Store the original ObjectId format consistently in the database
- Document why numeric IDs need special handling
- Validate that the numeric ID is within acceptable bounds before conversion
| } else if (typeof itemId === 'number') { | |
| objectId = new ObjectId(itemId.toString().padStart(24, '0')) | |
| } else { | |
| throw new Error(`Invalid _id format: ${itemId}`) | |
| } else { | |
| throw new Error(`Invalid _id format: ${itemId}. Only valid ObjectId strings are supported.`) |
Bumps mongodb from 6.20.0 to 7.0.0.
Release notes
Sourced from mongodb's releases.
... (truncated)
Changelog
Sourced from mongodb's changelog.
... (truncated)
Commits
2512137chore(main): release 7.0.0 (#4667)e4881f5docs(NODE-7172): create v7 migration guide (#4751)53a4fb1docs: 6.21 docs (#4782)696664cfeat!(NODE-7286): update peer dependencies (#4780)517da84docs: add info about testing with different versions and the rosetta setup fo...252dab8test(NODE-7219): remove unused tests (#4767)76c98bbtest(NODE-5206): fix flaky sdam prose test (#4752)cb522bffix(NODE-7247): clarify #rewrapManyDataKey() parameter types (#4760)ec996e6chore(NODE-6945): remove dependency onv8-heapsnapshot(#4763)7d879fdtest(NODE-7280): remove test/mongodb.ts and its usage (#4766)Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting
@dependabot rebase.Dependabot commands and options
You can trigger Dependabot actions by commenting on this PR:
@dependabot rebasewill rebase this PR@dependabot recreatewill recreate this PR, overwriting any edits that have been made to it@dependabot mergewill merge this PR after your CI passes on it@dependabot squash and mergewill squash and merge this PR after your CI passes on it@dependabot cancel mergewill cancel a previously requested merge and block automerging@dependabot reopenwill reopen this PR if it is closed@dependabot closewill close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually@dependabot show <dependency name> ignore conditionswill show all of the ignore conditions of the specified dependency@dependabot ignore this major versionwill close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself)@dependabot ignore this minor versionwill close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself)@dependabot ignore this dependencywill close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)