hackclub / hackclub/hcb

[Transfers] Add idempotency key to UI form

Open
#12,903 1 comment 1 reaction 0 assignees View on GitHub
Dominant language
Ruby
Stars
870
Forks
138
Avg merge
1d 14h
Merged PRs (30d)
208

Description

Prevent a double click on submit button from creating two disbursements/transfers. We'll eventually add it to the API.

Ticket created because of this: https://hackclub.slack.com/archives/CN523HLKW/p1770307026474539
However, we determined that the specific example (in the link) above of a duplicate disbursement was due to user error (requested 1 minute apart from each other), rather than a double click.

Nevertheless, we should add more protection

To implement this, please:
1. Add a nullable idempotency_key string column to all transfer models (AchTransfer, Check, etc.)
2. Ensure the idempotency_key column is unique
3. Hook up the transfer forms to pass in a hidden idempotency_key form field/param.
4. In Javascript, generate a UUID for the idempotency_key. Make this reuseable (e.g. via a partial & stimulus controller).
5. Have the controller raise a friendly error when idempotency_key is found to be not unique.

Contributor guide

Open the contributing guide

Research direction

Locate the AchTransfer, Check, and other transfer models, their forms, and the relevant controller actions. Start by tracing how a transfer form is submitted and how transfer records are created, then inspect the existing JavaScript and Stimulus patterns for reusable form behavior. Done means every transfer form sends a generated UUID, duplicate keys are rejected with a friendly controller error, and the uniqueness constraint is covered by tests.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, ruby
Domain
databases, full-stack
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Active
Clarity
Mostly clear
Newbie friendliness
55/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.