Disputed: dependency error in trigger

In a DAML trigger I get this error:

Command failed: Disputed: dependency error: couldn’t find contract ContractId(005393ea021c2648423e2c585beb7ec3e478d8fa459ff874cccf2bd1900e562026)

There are a few different reasons for this but they all boil down to an inconsistency between different stages (mostly command interpretation and validation).

The most common one in a trigger context is a race condition, e.g., two parallel command submissions operating on the same contract id or contract key.

Another option which I believe also results in the same error is visibility errors where the contract isn’t found during interpretation due to visibility issues but validation determines that the contract does exist (e.g. attempts to delegate a fetch).

To add to what I said earlier, if this comes from a race condition this isn’t necessarily an issue. Triggers are usually structured such that they will automatically retry (a consequence of being state-based, if the command fails the state didn’t change so the condition that produced a command still holds), So if one command submission failed due to a race, the next time the rule will be triggered it might succeed.

However, you should try to keep contention to a minimum. Otherwise you’ll end up overloading the ledger and no commands will get through.