TemaDeveloper / TemaDeveloper/personal_planner

bug: notes/databases/[id] PATCH generic path mass-writes unvalidated rows (clobbers concurrent edits)

Open Beginner friendly
#49 0 comments 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

The generic fallback path of PATCH /api/notes/databases/[id] (src/app/api/notes/databases/[id]/route.ts:72-80) copies title/icon/properties/views/rows from the request body into $set with no shape validation. The full-rows replace is exactly the pattern the dedicated migrate/rowOrder branches above were written to avoid — their comments note that a full-rows snapshot "would clobber a concurrent in-flight cell edit". This generic path is reachable by any authenticated request even though the current client doesn't use it.

Failure scenario

A crafted or stale PATCH { rows: [...] } overwrites the entire authoritative rows array, dropping any concurrent per-cell edit; malformed properties/views can also be persisted and later feed computeRollup / migrateRowsForTypeChange.

Fix

Drop rows from the generic path (force row edits through the row endpoints) and validate properties/views shape before persisting.

Severity

Low-Medium (data-loss under concurrency).

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/notes/databases/[id]/route.ts:72-80 and compare the generic PATCH path with the migrate and rowOrder branches above. Ensure the generic path no longer accepts rows and validates properties and views before persistence; row edits should continue through their dedicated endpoints.

Written by the indexing model from the issue text.

Assessment

Tech stack
mongodb, nextjs, typescript
Domain
api, backend, database
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Quiet
Clarity
Clearly specified
Newbie friendliness
76/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.