Commit b93d28c
fix: use INSERT OR IGNORE to prevent vote race condition (#26)
The vote handler uses SELECT to check for duplicates, then INSERT. Two
concurrent requests can both pass the SELECT check. The UNIQUE
constraint on (coupon_id, voter_did) catches this at the DB level, but
the resulting constraint violation error returns a generic 500 instead
of the expected 409 response.
Use INSERT OR IGNORE so concurrent duplicate inserts are silently
ignored instead of throwing errors, while keeping the SELECT check for
user-friendly feedback on normal duplicate attempts.
Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>1 parent 5613469 commit b93d28c
1 file changed
Lines changed: 5 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
15 | 15 | | |
16 | 16 | | |
17 | 17 | | |
18 | | - | |
| 18 | + | |
19 | 19 | | |
20 | 20 | | |
21 | 21 | | |
22 | 22 | | |
23 | 23 | | |
24 | 24 | | |
25 | 25 | | |
26 | | - | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
27 | 30 | | |
28 | 31 | | |
29 | 32 | | |
| |||
0 commit comments