If you send continuous REST API calls to Salesforce using languages such as node.js or JavaScript, you may sometimes face the below error with PATCH call through REST using an external Id field which accepts only unique values.
Error: "duplicate value found: uuid__c duplicates value on record with id: 00XXXXXXXXXXXXX".
You may wonder why you are getting duplicate error while you are doing a patch operation, which should either update the existing records or insert a new record?
The error itself does have some helpful information in that you are sending a duplicate record while the other is already present/being processed.
The scenario might be as follows:
Since multiple requests are being sent, there might be an overlapping request. That is, if the same record has been sent simultaneously/with milliseconds or seconds of a gap, it might be possible that the first records is under process while the second record is again taken up for processing. Then the server finds the second record as a duplicate and throws the error.
The best possible solution for this scenario would be to synchronize the requests.
000383480

We use three kinds of cookies on our websites: required, functional, and advertising. You can choose whether functional and advertising cookies apply. Click on the different cookie categories to find out more about each category and to change the default settings.
Privacy Statement
Required cookies are necessary for basic website functionality. Some examples include: session cookies needed to transmit the website, authentication cookies, and security cookies.
Functional cookies enhance functions, performance, and services on the website. Some examples include: cookies used to analyze site traffic, cookies used for market research, and cookies used to display advertising that is not directed to a particular individual.
Advertising cookies track activity across websites in order to understand a viewer’s interests, and direct them specific marketing. Some examples include: cookies used for remarketing, or interest-based advertising.