Steps to Repeat:
1. Install a clean, vanilla Drupal site
2. Delete the Basic page content type
3. Run drush cex
4. Create a second clean, vanilla Drupal site
5. Update the system.site uuid of the second site to match the first site
6. Copy exported config from first site into second
7. Run drush cim in the second site
Expected Results:
Configuration imports successfully.
Actual Results:
The import failed due for the following reasons: [error]
Unexpected error during import with operation delete for taxonomy.vocabulary.tags: Attempt to create a field body that
does not exist on entity type node.
Unexpected error during import with operation delete for node.type.article: Attempt to create a field body that does not
exist on entity type node.
Unexpected error during import with operation delete for comment.type.comment: Attempt to create a field body that does
not exist on entity type node.
Unexpected error during import with operation delete for block_content.type.basic: Attempt to create a field body that
does not exist on entity type node.
Unexpected error during import with operation delete for field.field.node.page.body: Attempt to create a field body that
does not exist on entity type node.
Unexpected error during import with operation delete for node.type.page: Attempt to create a field body that does not
exist on entity type node.
This is particularly problematic if you use BLT. In the CI environment, BLT spins up a fresh Drupal install and imports the config from disk in order to execute all of the site's automated tests. Once you delete the Basic page content type, your CI build will fail.
Workaround:
Run drush cdel field.field.node.article.body
and drush cdel field.field.node.page.body
and the config imports successfully.
Comments
Comment #2
atackett CreditAttribution: atackett commentedComment #3
alexpott@atackett the problem here is that just adjusting the system.site uuid is not enough. This is why #2788777: Allow a site-specific profile to be installed from existing config is such an important issue.
Comment #6
sodell CreditAttribution: sodell as a volunteer commentedI am running a few commands before import to clear out existing config.
drush cdel field.field.node.article.body
drush cdel field.field.node.page.body
drush ev '\Drupal::entityManager()->getStorage("shortcut_set")->load("default")->delete();'
Comment #9
pameeela CreditAttribution: pameeela commentedUpdated IS to add the workaround from #6, which works. Also added #2583113: Config import from a different site fails because of shortcut.set.default.yml as related because it's also a blocker to importing config from a different site, after changing the UUID.
Comment #10
pameeela CreditAttribution: pameeela commentedComment #14
samaphpIt seems to be a dependency issue.
I ran into the same issue. As per the suggestion by @sodell #6 I thought to delete the field storage itself instead of deleting the body field instances one by one from all used content types.
So, as a workaround I used this command before starting to import the config:
CAUTION: Please be aware that the data inside this body field will be lost. use this command for new installations only!
drush ev '\Drupal\field\Entity\FieldStorageConfig::loadByName("node", "body")->delete();'
This will delete the node body field storage and will fix the problem since the field storage will be re-imported again.
BUT It will fail if the node body does not exist. So, you may need to check if the node still exists to allow the command to be executed multiple times with no errors. which is this command:
drush ev '$f = \Drupal\field\Entity\FieldStorageConfig::loadByName("node", "body"); if($f) $f->delete();'