Check the key before rewriting any of it. I spent a week on rollback logic when the actual bug was that the mutation wrote to a key with a filter in it and the list read from the key without.
Everything looked correct in isolation. The optimistic write simply landed somewhere nothing was reading.