TemaDeveloper / TemaDeveloper/personal_planner
bug: sections/[slug]/entries GET 500s on invalid from/to date params
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 2
- Forks
- 4
- PR merge metrics
- No merged PRs in 30d
Description
Description
src/app/api/sections/[slug]/entries/route.ts:44-58 builds a Mongo date range from unvalidated query params: const fromDate = new Date(from); const toDate = new Date(to); (no NaN check), used directly in $gte/$lte. The handler has no try/catch.
Failure scenario
GET /api/sections/<slug>/entries?from=abc&to=def → new Date("abc") is an Invalid Date → the driver fails to serialize a non-finite date → uncaught rejection → 500. Should be a 400 or an empty/ignored filter.
Fix
Validate both dates with Number.isNaN(d.getTime()) and return 400 (or drop the filter) before querying.
Severity
Low (robustness).
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.
Research direction
Start in src/app/api/sections/[slug]/entries/route.ts, especially lines 44-58, and reproduce the GET request with invalid from/to values. Validate that invalid dates are handled before the MongoDB query and that the endpoint no longer returns an uncaught 500, while valid date filters continue to work.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- mongodb, typescript
- Domain
- api, database
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Quiet
- Clarity
- Clearly specified
- Newbie friendliness
- 78/100