Config Import fails with: Deleted and replaced configuration "front_page.settings"

Created on 22 May 2024, about 1 year ago

Problem/Motivation

Importing configuration with drush config:import fails if no config is present for front_page module and a role gets deleted during configuration import (not related to this module).

Steps to reproduce

  1. Prepare configuration to import: front_page.settings.yml and user.role.***.yml which will cause the role to be deleted or update (delete and re-create)
  2. Ensure front_page.settings is not exist in config table in DB
  3. Run drush cim --partial
  4. [error] Drupal\Core\Config\ConfigException: Errors occurred during import in Drush\Drupal\Commands\config\ConfigImportCommands->doImport()

    In ConfigImportCommands.php line 324:

    The import failed due to the following reasons:
    Deleted and replaced configuration "front_page.settings"

Proposed resolution

front_page_user_role_delete removes rid_* key from the config, but if config was missing this creates a default config object. Before import this config was not present so config:import tries to create it but fails as config is already created when a role is deleted in the import process.

So, front_page_user_role_delete should check if config is present, and if not present don't try to remove a non-existent key from it and create the config as a side-effect.

🐛 Bug report
Status

Active

Version

10.0

Component

Code

Created by

Live updates comments and jobs are added and updated live.
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.

  • Issue was unassigned.
  • Status changed to Needs review about 1 year ago
  • 🇳🇴Norway gisle Norway

    We need the community to review MR!16.

  • First commit to issue fork.
  • 🇦🇺Australia elc

    elc changed the visibility of the branch 10.x-3448931-fixconfimport to hidden.

  • 🇦🇺Australia elc

    Issue working branch should be named something unique, such as 10.x-3448931-fixconfimport instead of matching an upstream release branch name. In this case calling the issue branch 10.x means that people have to manually intervene in their local repo to be able to pull and push from different branch names.

    Re-rolled for recent release. Fixed up comment wrapping. Patch works for me on a new site before the settings have been saved.

    This begs the question, why doesn't this module have a default config for install?

  • @semseysandor opened merge request.
Production build 0.71.5 2024