Bridge lambda used the external account ID as the idempotency key when creating a linked liquidation address to prevent it being created twice (which happened in local dev, since each useEffect runs twice).
However, as a result when the create address call fails, it cannot be retried due to the idempotency key having been used already.
This PR changes the idempotency key to a random uuid as in other calls to Bridge API.
Testing
Sadly the instructions below do not work with Sandbox which doesn't complain about reusing idempotency keys. I ran those against production and it fixes the issue.
To test, we'll need to simulate a failed Bridge API call and then retry it.
1. Create an .env file inside bridgeXYZMutation directory and copy over the values from .env.example.
[!IMPORTANT]
Let me know if you need the API key for Bridge sandbox.
2. Complete KYC, but don't add any bank details yet.
[!IMPORTANT]
Try to use a "fresh" email address, otherwise you may already have bank details stored against your customer.
3. Apply the following patch (save as a file, then run git apply <filename>). It makes the payload of create liquidation address call invalid and it'll be rejected by Bridge.
Description
Bridge lambda used the external account ID as the idempotency key when creating a linked liquidation address to prevent it being created twice (which happened in local dev, since each useEffect runs twice).
However, as a result when the create address call fails, it cannot be retried due to the idempotency key having been used already.
This PR changes the idempotency key to a random uuid as in other calls to Bridge API.
Testing
Sadly the instructions below do not work with Sandbox which doesn't complain about reusing idempotency keys. I ran those against production and it fixes the issue.
To test, we'll need to simulate a failed Bridge API call and then retry it.1. Create an.env
file insidebridgeXYZMutation
directory and copy over the values from.env.example
.2. Complete KYC, but don't add any bank details yet.3. Apply the following patch (save as a file, then rungit apply <filename>
). It makes the payload of create liquidation address call invalid and it'll be rejected by Bridge.4. Go back to C2F account area and add USD bank details (EUR is not supported in sandbox). You can use the following test details:Notice no liquidation address shows up.5. Revert the changes applied with the patch and refresh the page.The liquidation address should show up.Onmaster
, the retried calls would fail due to using the same idempotency key, and the flow would be stuck.