Drupal\field\Plugin\Core\Entity\FieldInstance::saveNew() has code to check that an instance for that field doesn't already exist for that entiy_type+bundle (and raise an exception if that's already the case)
In practice, this just means checking that an configEntity with the same id doesn't already exist.
That is, prevent someone from doing :
entity_create('field_instance', $array) // where $array points to an already existing FieldInstance in the current active config
->save(); // Overrides the FieldInstance that was already there, goodbye...
There's no real reason why this check would make sense for FieldInstance config entities only. This should be checked automatically for all config entities
Comments
Comment #1
xjmRelated: #1998664: An existing block instance will be overwritten by a newly created block instance if the two share the same machine_name, #1969698: ConfigEntity::save() should disallow saving ID/UUID conflicts (Field UUID changes can badly corrupt field data), #1989674: Throw an exception in Entity::save() if the UUID is changed
Comment #2
alexpottThis is a duplicate of #1887654: Creating a config entity with an existing machine name shouldn't work