“Developer name already exists for custom metadata of this type” while pushing source to scratch org for 2gp managed package

2gp

We have an internal (non app exchange) 2gp managed package. The source is composed of a main package and several supporting packages with protected custom metadata. The errors below are from the source of a supporting package in the same namespace. Development was active several months ago and we were creating scratch orgs and pushing source regularly. Now it appears that Salesforce is confusing previously released metadata with an attempt to create new metadata. I don't believe that the source has changed location since the last time we built the package. I don't have any idea on how to resolve this since I'm not adding any new metadata to the package and just trying to push existing metadata to a new scratch org.

sfdx force:source:push -u P
*** Pushing v48.0 metadata with SOAP API v53.0 connection ***
DEPLOY PROGRESS | ████████████████████████████████████████ | 70/70 Components

=== Component Failures [4]
Type   Name              Problem
─────  ────────────────  ──────────────────────────────────────────────────────────────────────────────────────────────────
Error  X.Y  Developer name already exists for custom metadata of this type. Please choose a different name.
Error  X.Y  Developer name already exists for custom metadata of this type. Please choose a different name.
Error  XX     This Remote Site Name already exists or has been previously used.  Please choose a different name.
Error  XX     This Remote Site Name already exists or has been previously used.  Please choose a different name.

Best Answer

This turned out to be pure user error. I found that duplicate copies of the same metadata row appeared in different parts of the source tree when I pulled from master. It was very obvious (and a bit embarrassing) when Salesforce support pointed this out to me. Oh well we all make mistakes!