We have a Duplicate Rule defined on Contact Object.
The requirement is to insert or update Contact records in Batch apex. Ideally, if any duplicate is found I should get Duplicate Error in apex.
While implementing this use case, I have seen a weird behavior that when execute method is called for 1st set of Contacts, I am able to insert duplicate contacts with no errors, ideally it should error out and when execute method is called for 2nd set of Contacts then I am seeing duplicate contact error if any duplicate is found.
Why would apex not show Duplicate Error while inserting Duplicate contacts?
When I try from UI, I get proper Duplicate error message.