During config import: Exception "Argument 1 passed to Drupal\Component\Utility\NestedArray::setValue() must be of the type array, bool given"

Created on 18 November 2022, about 2 years ago
Updated 6 January 2024, 12 months ago

Problem

I use config_split_ignore (version 1.9.0) module and have some corrupted data.

I got the following error while running configuration import in a multisite platform (Drupal 9.4.8) hosted on Acquia site factory.

 [error]  TypeError: Argument 1 passed to Drupal\Component\Utility\NestedArray::setValue() must be of the type array, bool given, called in /mnt/www/html/XXXXXacsf01stage/docroot/modules/contrib/config_split_ignore/src/Plugin/ConfigFilter/ConfigSplitIgnoreFilter.php on line 152 in Drupal\Component\Utility\NestedArray::setValue() (line 147 of /mnt/www/html/XXXXXacsf01stage/docroot/core/lib/Drupal/Component/Utility/NestedArray.php) #0 /mnt/www/html/XXXXXacsf01stage/docroot/modules/contrib/config_split_ignore/src/Plugin/ConfigFilter/ConfigSplitIgnoreFilter.php(152): Drupal\Component\Utility\NestedArray::setValue(false, Array, Array, true)
#1 /mnt/www/html/XXXXXacsf01stage/docroot/modules/contrib/config_ignore/src/Plugin/ConfigFilter/IgnoreFilter.php(234): Drupal\config_split_ignore\Plugin\ConfigFilter\ConfigSplitIgnoreFilter->activeRead('search_api.inde...', false)
#2 /mnt/www/html/XXXXXacsf01stage/docroot/modules/contrib/config_filter/src/Config/FilteredStorage.php(73): Drupal\config_ignore\Plugin\ConfigFilter\IgnoreFilter->filterRead('search_api.inde...', false)
#3 /mnt/www/html/XXXXXacsf01stage/docroot/modules/contrib/config_filter/src/Config/FilteredStorage.php(178): Drupal\config_filter\Config\FilteredStorage->read('search_api.inde...')
#4 [internal function]: Drupal\config_filter\Config\FilteredStorage->Drupal\config_filter\Config\{closure}('search_api.inde...')
#5 /mnt/www/html/XXXXXacsf01stage/docroot/modules/contrib/config_filter/src/Config/FilteredStorage.php(179): array_filter(Array, Object(Closure))
#6 /mnt/www/html/XXXXXacsf01stage/docroot/modules/contrib/config_filter/src/ConfigFilterEventSubscriber.php(114): Drupal\config_filter\Config\FilteredStorage->listAll()
#7 /mnt/www/html/XXXXXacsf01stage/docroot/modules/contrib/config_filter/src/ConfigFilterEventSubscriber.php(58): Drupal\config_filter\ConfigFilterEventSubscriber::replaceAllStorageContents(Object(Drupal\config_filter\Config\FilteredStorage), Object(Drupal\Core\Config\MemoryStorage))
#8 [internal function]: Drupal\config_filter\ConfigFilterEventSubscriber->onImportTransform(Object(Drupal\Core\Config\StorageTransformEvent), 'config.transfor...', Object(Drupal\Component\EventDispatcher\ContainerAwareEventDispatcher))
#9 /mnt/www/html/XXXXXacsf01stage/docroot/core/lib/Drupal/Component/EventDispatcher/ContainerAwareEventDispatcher.php(142): call_user_func(Array, Object(Drupal\Core\Config\StorageTransformEvent), 'config.transfor...', Object(Drupal\Component\EventDispatcher\ContainerAwareEventDispatcher))
#10 /mnt/www/html/XXXXXacsf01stage/docroot/core/lib/Drupal/Core/Config/ImportStorageTransformer.php(120): Drupal\Component\EventDispatcher\ContainerAwareEventDispatcher->dispatch(Object(Drupal\Core\Config\StorageTransformEvent), 'config.transfor...')
#11 /mnt/www/html/XXXXXacsf01stage/vendor/drush/drush/src/Drupal/Commands/config/ConfigImportCommands.php(237): Drupal\Core\Config\ImportStorageTransformer->transform(Object(Drupal\Core\Config\FileStorage))
#12 [internal function]: Drush\Drupal\Commands\config\ConfigImportCommands->import(Array)
#13 /mnt/www/html/XXXXXacsf01stage/vendor/consolidation/annotated-command/src/CommandProcessor.php(257): call_user_func_array(Array, Array)
#14 /mnt/www/html/XXXXXacsf01stage/vendor/consolidation/annotated-command/src/CommandProcessor.php(212): Consolidation\AnnotatedCommand\CommandProcessor->runCommandCallback(Array, Object(Consolidation\AnnotatedCommand\CommandData))
#15 /mnt/www/html/XXXXXacsf01stage/vendor/consolidation/annotated-command/src/CommandProcessor.php(176): Consolidation\AnnotatedCommand\CommandProcessor->validateRunAndAlter(Array, Array, Object(Consolidation\AnnotatedCommand\CommandData))
#16 /mnt/www/html/XXXXXacsf01stage/vendor/consolidation/annotated-command/src/AnnotatedCommand.php(350): Consolidation\AnnotatedCommand\CommandProcessor->process(Object(Symfony\Component\Console\Output\ConsoleOutput), Array, Array, Object(Consolidation\AnnotatedCommand\CommandData))
#17 /mnt/www/html/XXXXXacsf01stage/vendor/symfony/console/Command/Command.php(255): Consolidation\AnnotatedCommand\AnnotatedCommand->execute(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#18 /mnt/www/html/XXXXXacsf01stage/vendor/symfony/console/Application.php(1039): Symfony\Component\Console\Command\Command->run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#19 /mnt/www/html/XXXXXacsf01stage/vendor/symfony/console/Application.php(275): Symfony\Component\Console\Application->doRunCommand(Object(Consolidation\AnnotatedCommand\AnnotatedCommand), Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#20 /mnt/www/html/XXXXXacsf01stage/vendor/symfony/console/Application.php(149): Symfony\Component\Console\Application->doRun(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#21 /mnt/www/html/XXXXXacsf01stage/vendor/drush/drush/src/Runtime/Runtime.php(124): Symfony\Component\Console\Application->run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#22 /mnt/www/html/XXXXXacsf01stage/vendor/drush/drush/src/Runtime/Runtime.php(51): Drush\Runtime\Runtime->doRun(Array, Object(Symfony\Component\Console\Output\ConsoleOutput))
#23 /mnt/www/html/XXXXXacsf01stage/vendor/drush/drush/drush.php(72): Drush\Runtime\Runtime->run(Array)
#24 /mnt/www/html/XXXXXacsf01stage/vendor/drush/drush/drush(4): require('/mnt/www/html/b...')
#25 {main}. 
TypeError: Argument 1 passed to Drupal\Component\Utility\NestedArray::setValue() must be of the type array, bool given, called in /mnt/www/html/XXXXXacsf01stage/docroot/modules/contrib/config_split_ignore/src/Plugin/ConfigFilter/ConfigSplitIgnoreFilter.php on line 152 in Drupal\Component\Utility\NestedArray::setValue() (line 147 of /mnt/www/html/XXXXXacsf01stage/docroot/core/lib/Drupal/Component/Utility/NestedArray.php).
 [warning] Drush command terminated abnormally.
Connection to server closed.

Proposed Solution

Inside the function activeRead on https://git.drupalcode.org/project/config_split_ignore/-/blob/8.x-1.x/sr... we can see the following check:

$active = $this->active->read($name);
    if (!$active) {
      return $data;
    }

The class ConfigSplitIgnoreFilter is extending the IgnoreFilter class from config_ignore module and is overriding the activeRead function but is not doing the same checks that his parent function.

For example in the config_ignore module the validation after the "is configuration active" check is a bit different: https://git.drupalcode.org/project/config_ignore/-/blob/8.x-2.x/src/Plug...

$active = $this->active->read($name);
if (!$active || !$data) {
      return $data;
    }

As we can see there is also a check on the $data variable and this is what we should do in the activeRead function from this module.

🐛 Bug report
Status

Fixed

Version

1.9

Component

Code

Created by

🇯🇵Japan eleonel Itoshima 🇯🇵

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.

Production build 0.71.5 2024