Hacktoberfest 2026: the issues maintainers tagged for October, open and beginner-friendly. Browse Hacktoberfest issues

bug: profile/generate idempotency guard is check-then-act → duplicate planners on concurrent submit

Open
#46 0 comments 0 reactions 0 assignees View on GitHub

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
Domain
api, backend, database

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

bug

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

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.

More from TemaDeveloper/personal_planner

All issues in TemaDeveloper/personal_planner

Similar issues

More TypeScript issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.