Skip to content

Validate task IDs in bulkDeleteTasks#1445

Open
Snnehamaurya wants to merge 2 commits into
aryandas2911:mainfrom
Snnehamaurya:fix-bulk-delete-objectid-validation
Open

Validate task IDs in bulkDeleteTasks#1445
Snnehamaurya wants to merge 2 commits into
aryandas2911:mainfrom
Snnehamaurya:fix-bulk-delete-objectid-validation

Conversation

@Snnehamaurya
Copy link
Copy Markdown

📌 Description

Added validation for task IDs in the bulkDeleteTasks controller to ensure all IDs are valid MongoDB ObjectIds before performing delete operations.

🔗 Related Issue

Closes #1358

🛠 Changes Made

  • Added validation for each task ID using mongoose.Types.ObjectId.isValid()
  • Return 400 Bad Request when an invalid task ID is provided
  • Prevent Mongoose cast errors from causing 500 Internal Server Error responses

📸 Screenshots (if applicable)

N/A (Backend-only change)

✅ Checklist

  • Followed project structure
  • No console errors related to the implemented change
  • Linked the issue
  • Code runs locally
  • Properly tested changes

🚀 Notes for Reviewers

This change validates all task IDs received in the bulk delete request before calling Task.deleteMany() and Routine.updateMany(). If any invalid ID is found, the API returns a 400 response with the message: "Invalid task ID provided".

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: Bulk delete API does not validate task IDs before deleting

1 participant