Problem/Motivation

Issue #3544715: Add oop support to hooks currently supported by themes brought us theme OOP hooks. To do so ConfigInstaller has to rebuild the container, like ModuleInstaller does.
What was forgotten there was duplicating the ::reinjectMe() codepath from modules to themes too in the ConfigImporter.
The result: All sorts of likely hard to spot container DI issues on cli install, likely breaking the install (thus major).
- This report: retrieving a synthetic service ("kernel") throws
- the other report (#3569677: 3544715 breaks RequestStack on existing-config-install): some services have an empty RequestStack

Steps to reproduce

  1. Prepare a site with an existing configuration export.
  2. Ensure the configuration includes items that trigger theme-related updates. In our case, this error is triggered when webform.webform_options.* (provided by the Webform module) is being imported.
  3. Run the installation command: drush site:install --existing-config

Proposed resolution

In ConfigImporter, do the same container rebuild handling for themes that is done for modules.

Remaining tasks

- Write a test
- ConfigImporterTest seems to be the place for it. This class currently has no test for the ModuleHandler ::reinjectMe code path.
- There is ::testInstallBaseAndSubThemes though, which might be nice to extend.
- Test inspired by this report: $container->get('kernel')
- Test inspired by the dup report: $container->get('request_stack') ... contains request
- Decide whether that other line from the module codepath must be duplicated and tested too: $this->moduleHandler->loadAll();
- review, commit, stop having pain

Original report

This issue occurs in Drupal 11.3.1, while it does not occur in Drupal 11.2.10.

When performing a non-interactive installation from existing configuration (e.g., using drush site:install --existing-config), the following error may occur during the configuration import process:

You have requested a synthetic service ("kernel"). The DIC does not know how to construct this service.

In Drupal 11.3, the ThemeInstaller (theme_installer service) was updated. It appears that DrupalKernel::updateThemes() now triggers a container re-initialization.

Within ConfigImporter::processExtension(), after the theme_installer service is executed, it seems necessary to re-inject the services (similar to how it is handled for modules) to prevent the service container from losing track of synthetic services like the kernel.

CommentFileSizeAuthor
#18 3564735-18.patch1.04 KBhmdnawaz

Issue fork drupal-3564735

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

kazuko.murata created an issue. See original summary.

kazuko.murata’s picture

Version: 11.3.x-dev » 11.x-dev

nicxvan’s picture

Thank you for finding this!

This will likely need a test too.

kazuko.murata’s picture

Status: Active » Needs review

I’ve opened a Merge Request to fix this bug and confirmed via manual testing that it works as expected.
I’d appreciate it if you could review the MR and let me know if there’s anything else I should do.

smustgrave’s picture

Status: Needs review » Needs work
Issue tags: +Needs tests, +Needs issue summary update

Thanks for reporting.

Summary appears to be missing a few sections from the template. Most importantly the proposed solution section.

Believe #4 meant we will need a test case or new assertion on an existing test that shows the problem described here.

Version: 11.x-dev » main

Drupal core is now using the main branch as the primary development branch. New developments and disruptive changes should now be targeted to the main branch.

Read more in the announcement.

nicxvan’s picture

There was a duplicate of #3569677: 3544715 breaks RequestStack on existing-config-install

Please restore the issue summary. I wonder if this is a drush issue?

What does drush do under the hood with that command?

geek-merlin’s picture

Priority: Normal » Major
Issue summary: View changes
Issue tags: -Needs issue summary update

Here we go with an updated IS. Which should make clear that this is not a drush issue.

geek-merlin’s picture

Title: Synthetic service (kernel)" error during non-interactive install from existing config in Drupal 11.3 » Container / service exceptions after installed from existing config via CLI

Made the title more general to not provoke more dups.

geek-merlin’s picture

Title: Container / service exceptions after installed from existing config via CLI » Container / service exceptions while installed from existing config via CLI
geek-merlin’s picture

Title: Container / service exceptions while installed from existing config via CLI » Container / service exceptions while installed from existing config
heddn’s picture

I can confirm the fixes here resolve an issue with a functional test I had that was installing existing config. No drush was involved, just pure phpunit.

geek-merlin’s picture

@heddn Can u share that test?

heddn’s picture

jeroent’s picture

Ran into this problem during a site install (drush si --existing-config), which resulted in the following error:

[error]  Unexpected error during import with operation create for webform.webform_options.country_codes: You have requested a synthetic service ("kernel"). The DIC does not know how to construct this service. 

MR 14169 fixed the problem for me.

steinmb’s picture

Our Behat pipeline failed installing from existing config on D11.3.x.

 [error]  Unexpected error during import with operation create for webform.webform_options.country_codes: 
You have requested a synthetic service ("kernel"). The DIC does not know how to construct this service. 

The suggested patch fixed it.

hmdnawaz’s picture

StatusFileSize
new1.04 KB

Patch from the MR

phenaproxima made their first commit to this issue’s fork.

phenaproxima’s picture

Status: Needs work » Needs review
Issue tags: -Needs tests

Wrote a test which, at least locally, fails as expected without the fix. This is ready for review.

balsama’s picture

Status: Needs review » Reviewed & tested by the community

Using this patch in a custom Drupal CMS Project scaffold and I can confirm functionally it fixes the exceptions thrown during install from config.

alexpott’s picture

Version: main » 11.3.x-dev

Committed and pushed 24b60a5c648 to main and a76b3fa0cb2 to 11.x and 5226fc8ae10 to 11.3.x. Thanks!

  • alexpott committed 5226fc8a on 11.3.x
    fix: #3564735 Container / service exceptions while installed from...

  • alexpott committed a76b3fa0 on 11.x
    fix: #3564735 Container / service exceptions while installed from...

  • alexpott committed 24b60a5c on main
    fix: #3564735 Container / service exceptions while installed from...
alexpott’s picture

Status: Reviewed & tested by the community » Fixed

Now that this issue is closed, review the contribution record.

As a contributor, attribute any organization that helped you, or if you volunteered your own time.

Maintainers, credit people who helped resolve this issue.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.