Skip to content

Commit 45c2f48

Browse files
Merge branch 'main' into dependabot/npm_and_yarn/mongodb-7.0.0
2 parents c459997 + c289d6f commit 45c2f48

File tree

8 files changed

+945
-910
lines changed

8 files changed

+945
-910
lines changed

CHANGELOG.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,10 @@
1+
## [2.22.5](https://github.com/device-management-toolkit/mps/compare/v2.22.4...v2.22.5) (2025-11-07)
2+
3+
4+
### Bug Fixes
5+
6+
* loosens UUID check for API ([#2194](https://github.com/device-management-toolkit/mps/issues/2194)) ([f741380](https://github.com/device-management-toolkit/mps/commit/f741380937cfc8f69a26d2ca4ef13fccbafcff2e))
7+
18
## [2.22.4](https://github.com/device-management-toolkit/mps/compare/v2.22.3...v2.22.4) (2025-11-06)
29

310
## [2.22.3](https://github.com/device-management-toolkit/mps/compare/v2.22.2...v2.22.3) (2025-10-14)

package-lock.json

Lines changed: 68 additions & 88 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@open-amt-cloud-toolkit/mps",
3-
"version": "2.22.4",
3+
"version": "2.22.5",
44
"description": "Containerized MPS service for executing Intel® AMT features",
55
"homepage": "https://github.com/device-management-toolkit/mps",
66
"contributors": [
@@ -46,7 +46,7 @@
4646
"exponential-backoff": "^3.1.3",
4747
"express": "^4.21.2",
4848
"express-validator": "^7.3.0",
49-
"got": "^14.6.2",
49+
"got": "^14.6.3",
5050
"http-z": "^7.0.0",
5151
"jws": "^4.0.0",
5252
"mongodb": "^7.0.0",
@@ -80,7 +80,7 @@
8080
"ts-jest": "^29.4.4",
8181
"ts-node": "^10.9.2",
8282
"typescript": "^5.8.3",
83-
"typescript-eslint": "8.46.3"
83+
"typescript-eslint": "8.46.4"
8484
},
8585
"optionalDependencies": {
8686
"fsevents": "^2.3.3"

src/data/mongo/collections/device.ts

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,23 @@ export class MongoDeviceTable implements IDeviceTable {
5555
}
5656

5757
async update(item: Device): Promise<WithId<Device>> {
58+
if (!(item as any)._id) {
59+
throw new Error('Device must have an _id for update operation')
60+
}
61+
62+
const itemId = (item as any)._id
63+
let objectId: ObjectId
64+
65+
if (ObjectId.isValid(itemId)) {
66+
objectId = new ObjectId(itemId)
67+
} else if (typeof itemId === 'number') {
68+
objectId = new ObjectId(itemId.toString().padStart(24, '0'))
69+
} else {
70+
throw new Error(`Invalid _id format: ${itemId}`)
71+
}
72+
5873
const result = await this.collection.findOneAndUpdate(
59-
{ _id: new ObjectId((item as any)._id as number), tenantId: item.tenantId },
74+
{ _id: objectId, tenantId: item.tenantId },
6075
{ $set: item },
6176
{ returnDocument: 'after', includeResultMetadata: false }
6277
)

src/routes/auth/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,6 @@ import { authorizeDevice } from './authorizeDevice.js'
1313
const authRouter: Router = Router()
1414

1515
authRouter.post('/', authValidator(), login)
16-
authRouter.get('/redirection/:guid', param('guid').isUUID(), validateMiddleware, authorizeDevice)
16+
authRouter.get('/redirection/:guid', param('guid').isUUID('loose'), validateMiddleware, authorizeDevice)
1717

1818
export default authRouter

src/routes/devices/deviceValidator.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
import { check, query } from 'express-validator'
77

88
export const validator = (): any => [
9-
check('guid').isUUID().isString(),
9+
check('guid').isUUID('loose').isString(),
1010
check('friendlyName').optional({ nullable: true }).isString(),
1111
check('hostname')
1212
.optional({ nullable: true })

0 commit comments

Comments
 (0)