Skip to content

fix: add taskId validation and remove throwaway formatted[] array in createRoutine and updateRoutine#1505

Open
Abhishek2005-ard wants to merge 36 commits into
aryandas2911:mainfrom
Abhishek2005-ard:fix/routine-create-taskid-validation
Open

fix: add taskId validation and remove throwaway formatted[] array in createRoutine and updateRoutine#1505
Abhishek2005-ard wants to merge 36 commits into
aryandas2911:mainfrom
Abhishek2005-ard:fix/routine-create-taskid-validation

Conversation

@Abhishek2005-ard

Copy link
Copy Markdown
Contributor

Summary

Fixes two bugs in backend/controllers/routineController.js inside the
createRoutine and updateRoutine functions:

  1. No taskId format validation — sending an invalid taskId caused a Mongoose
    cast error caught only by the generic 500 handler with no useful message.
  2. Throwaway formatted[] arrayendTime was computed into a separate array
    used only for overlap detection and then discarded. The actual items saved to DB
    never had endTime, creating inconsistent dead code.

Root Cause

Bug 1 — Missing taskId Validation

// ❌ Before — no validation on taskId
const newRoutine = new Routine({ userId, name, description, items });
// If items[n].taskId = "invalid-id", Mongoose throws a cast error → generic 500

Abhishek2005-ard and others added 30 commits May 27, 2026 14:06
@Abhishek2005-ard

Copy link
Copy Markdown
Contributor Author

close #1502

@Abhishek2005-ard

Copy link
Copy Markdown
Contributor Author

@aryandas2911
pls review this pr resolve conflicts sccessfull

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.

2 participants