How to fix DUPLICATE_VALUE in Salesforce deployments
A record or metadata component being created already has a matching unique value or Developer Name in the target org.
Surfaces during: both runtime DML inserts and metadata deploy validationWhat it means
DUPLICATE_VALUE means Salesforce rejected an insert or a new metadata component because something about it, a unique field value, an external ID, or a Developer Name, already exists in the target org. Salesforce enforces uniqueness at the platform level and will not silently overwrite the existing record or component.
It's a broader catch-all than DUPLICATE_DEVELOPER_NAME or DUPLICATE_EXTERNAL_ID; those are the two most common specific flavors, but this code can also fire on any custom field with the Unique attribute set.
Common causes
The fix
- Upsert instead of insertUse upsert with the correct external ID field so existing records are updated rather than re-created.
- Rename the colliding componentGive the newer metadata component a unique Developer Name and update any references to it.
- Review duplicate rules for test contextConfirm duplicate and matching rules do not block the specific record shapes your Apex tests insert.
How Serpent prevents this
Serpent AI flags overlapping Developer Names across concurrent tasks before either one reaches a deploy, so the collision is caught during scoping. See the Salesforce deployment error library.

Prevention
Related errors
DUPLICATE_VALUE, answered
Start free. No credit card, no install, no commitment.
Set up in under 15 minutes. No DevOps hire needed.
