fix: handle malformed IDs and allow empty set action

This commit is contained in:
ashu130698 committed 2026-03-05 18:02:55 +05:30
1 parent eb2d8b8d3b
commit 8eca81c8be
2 files changed
+14 -3

No files matched your search

@@ -304,7 +304,12 @@ class MongoMonitorsRepository implements IMonitorsRepository {
action: "add" | "remove" | "set",
teamId: string
): Promise<number> => {
const objectIds = monitorIds.map((id) => new mongoose.Types.ObjectId(id));
let objectIds;
try {
objectIds = monitorIds.map((id) => new mongoose.Types.ObjectId(id));
} catch {
throw new AppError({ message: "One or more monitor IDs are invalid", status: 400 });
}
const filter = { _id: { $in: objectIds }, teamId: new mongoose.Types.ObjectId(teamId) };
let update;