Config import fails with non existent theme reporting TypeError: array_diff():

Created on 19 October 2022, over 2 years ago
Updated 1 February 2023, over 2 years ago

Problem/Motivation

Import of single config of views.view.[viewname] fails dblog reports:

TypeError: array_diff(): Argument #1 ($array) must be of type array, null given in array_diff() (line 312 of /code/web/core/lib/Drupal/Core/EventSubscriber/ConfigImportSubscriber.php) 

#0 /code/web/core/lib/Drupal/Core/EventSubscriber/ConfigImportSubscriber.php(312): array_diff(NULL, Array)
#1 /code/web/core/lib/Drupal/Core/EventSubscriber/ConfigImportSubscriber.php(96): Drupal\Core\EventSubscriber\ConfigImportSubscriber->validateDependencies(Object(Drupal\Core\Config\ConfigImporter))
#2 [internal function]: Drupal\Core\EventSubscriber\ConfigImportSubscriber->onConfigImporterValidate(Object(Drupal\Core\Config\ConfigImporterEvent), 'config.importer...', Object(Drupal\Component\EventDispatcher\ContainerAwareEventDispatcher))
#3 /code/web/core/lib/Drupal/Component/EventDispatcher/ContainerAwareEventDispatcher.php(142): call_user_func(Array, Object(Drupal\Core\Config\ConfigImporterEvent), 'config.importer...', Object(Drupal\Component\EventDispatcher\ContainerAwareEventDispatcher))
#4 /code/web/core/lib/Drupal/Core/Config/ConfigImporter.php(756): Drupal\Component\EventDispatcher\ContainerAwareEventDispatcher->dispatch(Object(Drupal\Core\Config\ConfigImporterEvent), 'config.importer...')
#5 /code/web/core/modules/config/src/Form/ConfigSingleImportForm.php(377): Drupal\Core\Config\ConfigImporter->validate()
#6 [internal function]: Drupal\config\Form\ConfigSingleImportForm->validateForm(Array, Object(Drupal\Core\Form\FormState))
#7 /code/web/core/lib/Drupal/Core/Form/FormValidator.php(82): call_user_func_array(Array, Array)
#8 /code/web/core/lib/Drupal/Core/Form/FormValidator.php(275): Drupal\Core\Form\FormValidator->executeValidateHandlers(Array, Object(Drupal\Core\Form\FormState))
#9 /code/web/core/lib/Drupal/Core/Form/FormValidator.php(118): Drupal\Core\Form\FormValidator->doValidateForm(Array, Object(Drupal\Core\Form\FormState), 'config_single_i...')
#10 /code/web/core/lib/Drupal/Core/Form/FormBuilder.php(588): Drupal\Core\Form\FormValidator->validateForm('config_single_i...', Array, Object(Drupal\Core\Form\FormState))
#11 /code/web/core/lib/Drupal/Core/Form/FormBuilder.php(320): Drupal\Core\Form\FormBuilder->processForm('config_single_i...', Array, Object(Drupal\Core\Form\FormState))
#12 /code/web/core/lib/Drupal/Core/Controller/FormController.php(73): Drupal\Core\Form\FormBuilder->buildForm(Object(Drupal\config\Form\ConfigSingleImportForm), Object(Drupal\Core\Form\FormState))
#13 [internal function]: Drupal\Core\Controller\FormController->getContentResult(Object(Symfony\Component\HttpFoundation\Request), Object(Drupal\Core\Routing\RouteMatch))
#14 /code/web/core/lib/Drupal/Core/EventSubscriber/EarlyRenderingControllerWrapperSubscriber.php(123): call_user_func_array(Array, Array)
#15 /code/web/core/lib/Drupal/Core/Render/Renderer.php(564): Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}()
#16 /code/web/core/lib/Drupal/Core/EventSubscriber/EarlyRenderingControllerWrapperSubscriber.php(124): Drupal\Core\Render\Renderer->executeInRenderContext(Object(Drupal\Core\Render\RenderContext), Object(Closure))
#17 /code/web/core/lib/Drupal/Core/EventSubscriber/EarlyRenderingControllerWrapperSubscriber.php(97): Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->wrapControllerExecutionInRenderContext(Array, Array)
#18 /code/vendor/symfony/http-kernel/HttpKernel.php(159): Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}()
#19 /code/vendor/symfony/http-kernel/HttpKernel.php(81): Symfony\Component\HttpKernel\HttpKernel->handleRaw(Object(Symfony\Component\HttpFoundation\Request), 1)
#20 /code/web/core/lib/Drupal/Core/StackMiddleware/Session.php(58): Symfony\Component\HttpKernel\HttpKernel->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#21 /code/web/core/lib/Drupal/Core/StackMiddleware/KernelPreHandle.php(48): Drupal\Core\StackMiddleware\Session->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#22 /code/web/core/modules/page_cache/src/StackMiddleware/PageCache.php(106): Drupal\Core\StackMiddleware\KernelPreHandle->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#23 /code/web/core/modules/page_cache/src/StackMiddleware/PageCache.php(85): Drupal\page_cache\StackMiddleware\PageCache->pass(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#24 /code/web/core/lib/Drupal/Core/StackMiddleware/ReverseProxyMiddleware.php(48): Drupal\page_cache\StackMiddleware\PageCache->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#25 /code/web/core/lib/Drupal/Core/StackMiddleware/NegotiationMiddleware.php(51): Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#26 /code/vendor/stack/builder/src/Stack/StackedHttpKernel.php(23): Drupal\Core\StackMiddleware\NegotiationMiddleware->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#27 /code/web/core/lib/Drupal/Core/DrupalKernel.php(709): Stack\StackedHttpKernel->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#28 /code/web/index.php(19): Drupal\Core\DrupalKernel->handle(Object(Symfony\Component\HttpFoundation\Request))
#29 {main}

.

Steps to reproduce

Multiple attempts before and after applying all available updates for Core version 9.4.8
Export single config for views.view.[viewname].yml from UI /admin/config/development/configuration/single/export
Import from UI /admin/config/development/configuration/single/import

Proposed resolution

Remaining tasks

User interface changes

API changes

Data model changes

Release notes snippet

🐛 Bug report
Status

Active

Version

9.5

Component
Configuration 

Last updated 2 days ago

Created by

🇺🇸United States bsnodgrass

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.

  • 🇺🇸United States bsnodgrass

    @ https://www.drupal.org/u/jakegibs617 https://www.drupal.org/project/drupal/issues/3316271#comment-14878863 🐛 Config import fails with non existent theme reporting TypeError: array_diff(): Needs work appears to be the same error, but occurring on a different line.

    https://www.drupal.org/project/drupal/issues/3316271#comment-14878863 🐛 Config import fails with non existent theme reporting TypeError: array_diff(): Needs work is a different issue.

    The error is ambiguous and is difficult to track down. If I recall we looked at the code to determine what was actually failing and noticed old artifacts in config left over from our migration work moving from Drupal 6 to Drupal 8.

  • Status changed to Needs review about 2 years ago
  • 🇮🇳India Ranjit1032002

    Created a patch for the issue mentioned, please review.
    Thank You.

  • Status changed to Needs work about 2 years ago
  • 🇺🇸United States smustgrave

    #11 doesn't address the proposed solution "Better error messaging would be very helpful to identify what actually failed."

    Have imported views several times without issues, maybe it's a problem with the view?

    This will need test case though.

  • 🇨🇴Colombia alejo-moreno

    I'm getting a similar error when deploying to Acquia to one of the Dev databases. This is likely to happen in Prod in the next deploy but the detail of the error is not enough to spot the issue, which one could be the configuration failing? Even more weird that this just happens in Acquia and not in the local machine with the same database and code.

    |            | purge_queuer_coretags.settings       | Delete    |
    |            | purge.logger_channels                | Delete    |
    |            | new_relic_rpm.settings               | Delete    |
    +------------+--------------------------------------+-----------+
     [warning] Undefined array key "theme" ConfigImporter.php:456
     [error]  TypeError: array_diff_key(): Argument #1 ($array) must be of type array, null given in array_diff_key() (line 456 of /mnt/www/html/project_ucod/docroot/core/lib/Drupal/Core/Config/ConfigImporter.php) #0 /mnt/www/html/project_ucod/docroot/core/lib/Drupal/Core/Config/ConfigImporter.php(456): array_diff_key()
    #1 /mnt/www/html/project_ucod/docroot/core/lib/Drupal/Core/Config/ConfigImporter.php(777): Drupal\Core\Config\ConfigImporter->createExtensionChangelist()
    #2 /mnt/www/html/project_ucod/docroot/core/lib/Drupal/Core/Config/ConfigImporter.php(566): Drupal\Core\Config\ConfigImporter->validate()
    #3 /mnt/www/html/project_ucod/vendor/drush/drush/src/Drupal/Commands/config/ConfigImportCommands.php(296): Drupal\Core\Config\ConfigImporter->initialize()
    #4 [internal function]: Drush\Drupal\Commands\config\ConfigImportCommands->doImport()
    #5 /mnt/www/html/project_ucod/vendor/drush/drush/includes/drush.inc(122): call_user_func_array()
    #6 /mnt/www/html/project_ucod/vendor/drush/drush/includes/drush.inc(113): drush_call_user_func_array()
    #7 /mnt/www/html/project_ucod/vendor/drush/drush/src/Drupal/Commands/config/ConfigImportCommands.php(271): drush_op()
    #8 [internal function]: Drush\Drupal\Commands\config\ConfigImportCommands->import()
    #9 /mnt/www/html/project_ucod/vendor/consolidation/annotated-command/src/CommandProcessor.php(276): call_user_func_array()
    #10 /mnt/www/html/project_ucod/vendor/consolidation/annotated-command/src/CommandProcessor.php(212): Consolidation\AnnotatedCommand\CommandProcessor->runCommandCallback()
    #11 /mnt/www/html/project_ucod/vendor/consolidation/annotated-command/src/CommandProcessor.php(176): Consolidation\AnnotatedCommand\CommandProcessor->validateRunAndAlter()
    #12 /mnt/www/html/project_ucod/vendor/consolidation/annotated-command/src/AnnotatedCommand.php(391): Consolidation\AnnotatedCommand\CommandProcessor->process()
    #13 /mnt/www/html/project_ucod/vendor/symfony/console/Command/Command.php(255): Consolidation\AnnotatedCommand\AnnotatedCommand->execute()
    #14 /mnt/www/html/project_ucod/vendor/symfony/console/Application.php(1039): Symfony\Component\Console\Command\Command->run()
    #15 /mnt/www/html/project_ucod/vendor/symfony/console/Application.php(275): Symfony\Component\Console\Application->doRunCommand()
    #16 /mnt/www/html/project_ucod/vendor/symfony/console/Application.php(149): Symfony\Component\Console\Application->doRun()
    #17 /mnt/www/html/project_ucod/vendor/drush/drush/src/Runtime/Runtime.php(124): Symfony\Component\Console\Application->run()
    #18 /mnt/www/html/project_ucod/vendor/drush/drush/src/Runtime/Runtime.php(51): Drush\Runtime\Runtime->doRun()
    #19 /mnt/www/html/project_ucod/vendor/drush/drush/drush.php(79): Drush\Runtime\Runtime->run()
    #20 /mnt/www/html/project_ucod/vendor/drush/drush/drush(4): require('...')
    #21 /mnt/www/html/project_ucod/vendor/bin/drush(119): include('...')
    
  • 🇬🇧United Kingdom darren.fisher

    I resolved this by looking at: web/core/lib/Drupal/Core/EventSubscriber/ConfigImportSubscriber.php

    After line 289: $data = $config_importer->getStorageComparer()->getSourceStorage()->read($name);

    Put a var_dump: var_dump($data);

    This allowed me to search for instances of NULL and I found one in views.view.taxonomy_term.yml where I had:

    dependencies:
      -  config: null
    

    Removing the - config: null line fixed my import issues.

    THIS IS NOT A ONE FIX FITS ALL SITUATION!

    You need to find exactly where in your config there is an instance of NULL that shouldn't be there and get rid of it!!

    Good luck. Hope this helps!

  • 🇬🇧United Kingdom darren.fisher

    Alternatively you could find offending item (in my case the taxonomy term view) and edit it in the UI and then save it to see if the system can resolve the config on its own and then export that item and reimport. This is what fixed it for me!

  • 🇬🇧United Kingdom darren.fisher

    In terms of moving this issue on it might be helpful to create a branch from this issue and have Drupal log which config file contains the offending NULL instance so that it's easier to pinpoint where the error is occurring?

Production build 0.71.5 2024