fix(api): widen slugify suffix from 4 to 8 chars or add retry loop
Nobody has claimed this yet.
- Dominant language
- HTML
- Stars
- 33
- Forks
- 104
- Avg merge
- 12h 3m
- Merged PRs (30d)
- 10
Description
Summary
Event slug generation uses Math.random().toString(36).slice(2, 6) — a 4-character base36 suffix. Birthday-paradox math gives a collision rate around 1-in-1.6M per name, surfacing as a generic 500 from the unique-constraint insert. Low but non-zero.
Requirements
- Widen the suffix to 8 characters (~1-in-2.8B collision per name) OR add a
try/retryloop that regenerates on unique-constraint conflict - Files affected:
packages/api/src/routes/admin/events/index.ts,packages/api/src/routes/eventsSubmit.ts - If a shared
slug.tshelper lands first (#2002), apply the fix once there - Unit test: 10,000 random slugifies of the same name produce zero duplicates
Context
Flagged in the Plan 2 review. Forms (Plan 4) will also need slug generation — fix once and reuse.
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 by reading the slug generation in packages/api/src/routes/admin/events/index.ts and packages/api/src/routes/eventsSubmit.ts, then check whether shared slug.ts from #2002 exists. Run the relevant unit tests and add coverage for 10,000 slugs from the same name; done means duplicate-free generation and no generic unique-constraint failure path.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- typescript
- Domain
- api, backend
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 52/100