I started noticing this error while running my test suite. I can reproduce it by going into the temporary tenant created during the test run.
In this specific case, I have logic that runs on a workflow transition, which inserts Directory records. I initially thought the issue might be there, since the Autonumber Definition for Directory is based on ContactID.
However, I’m not actually passing ContactID when inserting Directory records, which made it confusing why the duplicate key error was happening in the first place?
Error Message: "AutomationError: The current transaction was aborted due to a prior failed database transaction. Most likely caused by: ERROR: duplicate key value violates unique constraint "kcuweltlq_a" Detail: Key (nwtenantstripe, nwnateid, ((nwdata ->> 'ContactID'::text)::double precision))=(stx_rpdevautoteststx_t192, 00000000-0000-0000-0000-000000000000, 1) already exists. Caused by: ERROR: current transaction is aborted, commands ignored until end of transaction block.