Skip to content

A sign-up without an email can be booked twice by a retry #387

Closed

Description

@richshaw

Follow-up to #378 and #385, which let participants leave the email blank where the organizer allows it.

What happens

With an email, a second POST /api/slots/[id]/commitments for the same person and slot finds the same participant and is refused: "you already committed to this slot". Without an email there is nothing to recognise them by. Every request creates a new participant, so that check can never match.

Here is a realistic case:

  1. A participant's phone loses its connection after the server commits the sign-up, but before the response arrives.
  2. The sign-up form shows "network error", and they press Confirm again.
  3. A second commitment is created.
  4. The first response's Set-Cookie was lost and no email is sent, so the first commitment has no link anywhere. It holds a place until the organizer removes it from the Responses tab (Organizers can remove one person from a slot #377).

A double click is already blocked, because the button is disabled while sending. A check based on the os_commit cookie doesn't help here, because the lost response is exactly the one that would have set the cookie.

Fix, in outline

  • The sign-up form makes an idempotency key when it opens (for example, a random id kept for the life of the dialog). It sends the key with the sign-up request.
  • The server stores the key with the commitment it creates. A repeat request with the same key returns that same commitment, with its edit link, instead of creating another.
  • This needs somewhere to keep the key. Per CLAUDE.md's "no speculative schema", add it in the same change that reads and writes it, and give it a short lifetime or tie it to the commitment row.
  • Keep POST /api/slots/[id]/commitments within its statement budgets (budgets.json, query-budget.db.test.ts).

Done when

  • Two identical sign-up requests with the same key create one commitment and both get its link back.
  • A request with a different key, or none, behaves as today.
  • DB and e2e tests cover the retry.
  • pnpm lint && pnpm typecheck && pnpm knip && pnpm test and pnpm test:db pass.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions