TemaDeveloper / TemaDeveloper/personal_planner

bug: sections/[slug]/entries GET 500s on invalid from/to date params

Open Beginner friendly
#48 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug
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=defnew 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

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.