Upgrading to 10.2 broke configuration

Created on 21 December 2023, 11 months ago
Updated 23 July 2024, 4 months ago

Problem/Motivation

After upgrading to version 10.2 configuration broke completely - configuration entities cannot be changed anymore (views), and database updates fail with the message:

  [notice] Update started: file_post_update_add_default_filename_sanitization_configuration
>  [error]  TypeError: Unsupported operand types: string + array in Drupal\Core\Config\TypedConfigManager->getDefinitionWithReplacements() (line 197 of /var/www/html/web/core/lib/Drupal/Core/Config/TypedConfigManager.php) #0 /var/www/html/web/core/lib/Drupal/Core/Config/TypedConfigManager.php(113): Drupal\Core\Config\TypedConfigManager->getDefinitionWithReplacements('langcode', Array)
> #1 /var/www/html/web/core/lib/Drupal/Core/Config/Schema/ArrayElement.php(153): Drupal\Core\Config\TypedConfigManager->buildDataDefinition(Array, 'et', 'langcode', Object(Drupal\Core\Config\Schema\Mapping))
> #2 /var/www/html/web/core/lib/Drupal/Core/Config/Schema/Mapping.php(26): Drupal\Core\Config\Schema\ArrayElement->buildDataDefinition(Array, 'et', 'langcode')
> #3 /var/www/html/web/core/lib/Drupal/Core/Config/Schema/ArrayElement.php(37): Drupal\Core\Config\Schema\Mapping->getElementDefinition('langcode')
> #4 /var/www/html/web/core/lib/Drupal/Core/Config/Schema/ArrayElement.php(85): Drupal\Core\Config\Schema\ArrayElement->parse()
> #5 /var/www/html/web/core/lib/Drupal/Core/Config/Schema/ArrayElement.php(59): Drupal\Core\Config\Schema\ArrayElement->getElements()
> #6 /var/www/html/web/core/lib/Drupal/Core/Config/StorableConfigBase.php(181): Drupal\Core\Config\Schema\ArrayElement->get('_core')
> #7 /var/www/html/web/core/lib/Drupal/Core/Config/StorableConfigBase.php(216): Drupal\Core\Config\StorableConfigBase->castValue('_core', Array)
> #8 /var/www/html/web/core/lib/Drupal/Core/Config/Config.php(211): Drupal\Core\Config\StorableConfigBase->castValue(NULL, Array)
> #9 /var/www/html/web/core/modules/file/file.post_update.php(44): Drupal\Core\Config\Config->save()
> #10 /var/www/html/vendor/drush/drush/src/Commands/core/UpdateDBCommands.php(280): file_post_update_add_default_filename_sanitization_configuration(Array)
> #11 /var/www/html/vendor/drush/drush/includes/batch.inc(257): Drush\Commands\core\UpdateDBCommands::updateDoOnePostUpdate('file_post_updat...', Array)
> #12 /var/www/html/vendor/drush/drush/includes/batch.inc(204): _drush_batch_worker()
> #13 /var/www/html/vendor/drush/drush/includes/batch.inc(75): _drush_batch_command('999')

Steps to reproduce

1. Update codebase to 10.2
2. Run database updates (either through browser or drush) - file_post_update_add_default_filename_sanitization_configuration fails (my other update hooks failed the same way if they tried to modify configuration) with the error above.
3. Try to log in and edit some view - white page with same error message

I was on the 10.1.7 version. It is a multilingual site, default language is not English.
The exported configuration looks fine, langcode is there and has a value.
Setting a simple configuration that does not have langcode with "drush cset" also fails with the same error.
Reverting to 10.1 makes it work again.

I tried to find the issue, but I did not find any clues what could be wrong - it tries to load langcode definition and fails because of that. Found CR that could be related: https://www.drupal.org/node/3373721 β†’

πŸ› Bug report
Status

Closed: works as designed

Version

10.2 ✨

Component
ConfigurationΒ  β†’

Last updated about 21 hours ago

Created by

πŸ‡ͺπŸ‡ͺEstonia rang501 Viljandi

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

  • Issue created by @rang501
  • πŸ‡ͺπŸ‡ͺEstonia rang501 Viljandi
  • πŸ‡ͺπŸ‡ͺEstonia rang501 Viljandi
  • What is the value $definition on line 196? It is supposed to be an array but it is something else. Can you set a debug breakpoint there or var_dump it if !is_array?

  • πŸ‡ͺπŸ‡ͺEstonia rang501 Viljandi

    The value of $definition, when the error is triggered is just 'en'.

    I also ruled out patches by removing them, still the same issue. Removed config_ui module as well, same issue.

  • Status changed to Closed: works as designed 11 months ago
  • πŸ‡ͺπŸ‡ͺEstonia rang501 Viljandi

    I found it - someone put a regular config file (which contained langcode) inside the config/schema directory and config schema discovery tried to parse it.

  • πŸ‡¨πŸ‡¦Canada arakwar

    To add more details on the next person who'll find this trough Google :

    We had a contrib module, admin Tooltips, who had a langcode key in one file in their config/schema folder.

    We found it by running a search on all **/config/schema/*.yml files, on the langcode key. Look for anything that isn't a field definition and remove them.

    Once we did that, it solved our issue.

    While I understand that this shouldn't happen as config schema should be clean, maybe the safeguard around this and the error message could be a bit more descriptive of the issue? I feel like I found the comment #6 by luck while it's exactly the right answer to our issue.

  • πŸ‡¨πŸ‡¦Canada xmacinfo Canada

    I had a langcode key in one file in my config/schema folder of a custom module.

    Thank you for the help on how to fix failed update.

Production build 0.71.5 2024