TemaDeveloper / TemaDeveloper/personal_planner
bug: notes/databases/[id] PATCH generic path mass-writes unvalidated rows (clobbers concurrent edits)
Nobody has claimed this yet.
- 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
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/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