bug: profile/generate idempotency guard is check-then-act → duplicate planners on concurrent submit
Nobody has claimed this yet.
Assessment
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Newbie friendliness
- 76/100
- Issue type
- Bug
- Clarity
- Clearly specified
- Activity status
- Quiet
- Tech stack
- mongodb, nextjs, typescript
Research direction
Start in src/app/api/profile/generate/route.ts, especially the guard at lines 36-42 and the onboardingDone write at lines 108-118. Trace the User model update and exercise overlapping POST requests; done means only one request can create templates and set onboardingDone, while the other exits without calling the AI or creating duplicates.
Written by the indexing model from the issue text.
Description
Description
src/app/api/profile/generate/route.ts guards against re-generation by reading user.onboardingDone (line 36-42), then later creating N templates and finally setting onboardingDone: true (line 108-118). The read and the write are not atomic and there is no per-user lock.
Failure scenario
The client double-submits (or a slow first request is retried while still in flight) so two POSTs overlap. Both read onboardingDone === false, both call the AI, and both create a full set of sections and push them to customSections. The user ends up with two complete, duplicated planners. (Sequential retries after success are correctly guarded; only the concurrent/overlapping case slips through.)
Fix
Gate with an atomic conditional update — User.updateOne({ _id, onboardingDone: { $ne: true } }, { $set: { onboardingDone: true } }) — and only proceed when modifiedCount === 1; or hold a per-user generation lock.
Severity
Medium.
- Dominant language
- TypeScript
- Stars
- 2
- Forks
- 4
- PR merge metrics
- No merged PRs in 30d
Getting set up
- No Dockerfile or Docker Compose file
- Has a pull request template
- Read the contributing 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 82/100
-
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
All issues in TemaDeveloper/personal_planner
Similar issues
-
Difficulty 2/5 Under an hour Newbie friendliness 85/100
capricorn86/happy-dom#2474 ·
Maintainers usually reply within 2 days
-
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
JSerwatka/letterboxd-tweaks#81 · 1 comment ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
siyuan-note/siyuan#20165 ·
Maintainers usually reply within 1 day
-
Difficulty 1/5 Under an hour Newbie friendliness 90/100
polkadot-js/phishing#5716 ·
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 90/100
juice-shop/juice-shop#3662 ·
Maintainers usually reply within 1 day