I have added task_id in unique_indices, but I was hoping to handle it consistently like other DuplicateResource errors in pulp, rather than a mongo DuplicateKeyError with traceback. Maybe I can just catch pymongo.errors.DuplicateKeyError here and then raise DuplicateResource instead of searching collection for that task_id.