bug: notes/databases/[id] GET/PATCH/DELETE 500 on malformed id (missing ObjectId.isValid)
Nobody has claimed this yet.
Assessment
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Newbie friendliness
- 82/100
- Issue type
- Bug
- Clarity
- Clearly specified
- Activity status
- Quiet
- Tech stack
- mongodb, typescript
Research direction
Start in src/app/api/notes/databases/[id]/route.ts and compare its GET, PATCH, and DELETE handlers with rows/route.ts and rows/[rowId]/route.ts, which show the existing validation pattern. Verify that malformed IDs return 404 rather than an uncaught CastError for all three handlers.
Written by the indexing model from the issue text.
Description
Description
src/app/api/notes/databases/[id]/route.ts passes the raw id straight into Mongoose (findOne/findOneAndUpdate/deleteOne({ _id: id, ... })) with no ObjectId.isValid guard and no try/catch — GET (:13-15), PATCH (:36/:78), DELETE (:87-88). A non-ObjectId id throws a Mongoose CastError that is never caught. The sibling row routes already validate (rows/route.ts:14, rows/[rowId]/route.ts:22), confirming the inconsistency.
Failure scenario
GET /api/notes/databases/not-an-id → uncaught CastError → 500 instead of a clean 404.
Fix
Add the same mongoose.Types.ObjectId.isValid(id) early-return-404 used by the row routes to all three handlers.
Severity
Low-Medium (robustness).
- Dominant language
- TypeScript
- Stars
- 2
- Forks
- 4
- PR merge metrics
- No merged PRs in 30d
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from TemaDeveloper/personal_planner
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
TemaDeveloper/personal_planner#48 · 1 comment ·
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
-
good first issue polish
Difficulty 2/5 Half a day Newbie friendliness 72/100
-
enhancement
Difficulty 5/5 Over a week Newbie friendliness 45/100
All issues in TemaDeveloper/personal_planner
Similar issues
-
calcite-components needs triage refactor
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
Esri/calcite-design-system#15203 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 91/100
-
community first-timers-only good first issue hacktoberfest help wanted low hanging fruit up-for-grabs
Difficulty 1/5 Under an hour Newbie friendliness 95/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
Automattic/studio#4908 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 90/100