Config import failing if language override is updated while original is recreated

Created on 18 November 2021, about 3 years ago
Updated 7 December 2023, about 1 year ago

Problem/Motivation

If you have a configuration (lets say: node.type.page) that is recreated (has a different UUID) and a language override that has been updated, it is impossible to import configuration.

Steps to reproduce

  • Enable the config_translation module.
  • Go to /admin/config/regional/language/add and add the Dutch language
  • Run a config export (drush cex -y)
  • Go to /admin/structure/types/manage/page/delete and delete the content type 'page'
  • Go to /admin/structure/types/add and add a new content type with the machine name 'page'
  • Go to /admin/structure/types/manage/page/translate/nl/add and add something random in all fields, and save.
  • Run a config import, either using the UI or drush.

You will see the error:
Update target "node.type.page" is missing.
The configuration was imported with errors.

With drush, you can see exactly why it goes wrong (left out irrelevant config):

$ drush cim
+-------------+--------------------------------------------+-----------+
| Collection  | Config                                     | Operation |
+-------------+--------------------------------------------+-----------+
|             | node.type.page                             | Create    |
|             | node.type.page                             | Delete    |
| language.nl | node.type.page                             | Update    |
+-------------+--------------------------------------------+-----------+

Import the listed configuration changes? (yes/no) [yes]:
 > 

 [notice] Synchronized configuration: delete node.type.page.
 [notice] Synchronized configuration: create node.type.page.
 [notice] Synchronized configuration: update node.type.page in language.nl.
 [notice] Finalizing configuration synchronization.
 [error]  Drupal\Core\Config\ConfigException: Errors occurred during import in Drush\Drupal\Commands\config\ConfigImportCommands->doImport() (line 346 of /var/www/html/vendor/drush/drush/src/Drupal/Commands/config/ConfigImportCommands.php). 

In ConfigImportCommands.php line 360:
                                                   
  The import failed due to the following reasons:  
  Update target "node.type.page" is missing.       
                                                   

Failed to run drush cim: exit status 1

When the config import is run again, it does work (because in the first run the config was deleted). But running the import twice is of course not the right fix.

Proposed resolution

If the UUID of a config item changes, it is marked as being deleted and re-created. We should also do that for all config overrides, so that if the untranslated version is re-created all language overrides are also marked as deleted and re-created.

Remaining tasks

Create MR.

User interface changes

None.

API changes

None.

Data model changes

None.

Release notes snippet

None.

πŸ› Bug report
Status

Needs work

Version

11.0 πŸ”₯

Component
ConfigurationΒ  β†’

Last updated 1 day ago

Created by

πŸ‡³πŸ‡±Netherlands bartlangelaan Netherlands

Live updates comments and jobs are added and updated live.
  • Needs subsystem maintainer review

    It is used to alert the maintainer(s) of a particular core subsystem that an issue significantly impacts their subsystem, and their signoff is needed (see the governance policy draft for more information). Also, if you use this tag, make sure the issue component is set to the correct subsystem. If an issue significantly impacts more than one subsystem, use needs framework manager review instead.

Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

  • πŸ‡ΊπŸ‡ΈUnited States smustgrave

    This issue is being reviewed by the kind folks in Slack, #needs-review-queue-initiative. We are working to keep the size of Needs Review queue [2700+ issues] to around 400 (1 month or less), following Review a patch or merge request β†’ as a guide.

    Following the steps in the issue summary I was able to reproduce this issue
    applying MR 1424 and rerunning drush cim I was able to import correctly

    Issue summary has steps, proposed solution, and clear problem

    looks good.

  • Status changed to Needs work almost 2 years ago
  • πŸ‡¬πŸ‡§United Kingdom catch
    +          // will lead to errors if this is marked as 'updated' while the
    +          // parent is recreated.
    +          // See: https://www.drupal.org/project/drupal/issues/3250066
    +          $recreate = TRUE;
    

    Nit, but we don't usually reference the issue that added the change because git blame does that for us.

    This looks good to me otherwise, but tagging for subsystem maintainer review so a config maintainer can have a look at it.

  • πŸ‡§πŸ‡ͺBelgium fernly

    The latest MR version worked for me.

Production build 0.71.5 2024