Problem/Motivation

Drupal\Component\Plugin\Exception\PluginNotFoundException thrown in Drupal\ Core \Plugin\DefaultPluginManager->doGetDefinition() (line 53 of core/lib/Drupal/Component/Plugin/Discovery/DiscoveryTrait.php when saving configuration in PolicyEditForm

The full error:

An unexpected error has occurred. Please try again later.

Drupal\Component\Plugin\Exception\PluginNotFoundException : The "" plugin does not exist. Valid plugin IDs for Drupal\symfony_mailer\Processor\EmailAdjusterManager are: email_plain, email_cc, email_priority, mailer_url_to_absolute, mailer_wrap_and_convert, email_to, email_subject, mailer_default_headers, email_bcc, mailer_hooks, email_body, email_from, email_theme, email_transport, mailer_inline_css, email_skip_sending, email_reply_to in Drupal\ Core \Plugin\DefaultPluginManager->doGetDefinition() (line 53 of core/lib/Drupal/Component/Plugin/Discovery/DiscoveryTrait.php ).
Drupal\Core\Plugin\DefaultPluginManager->getDefinition('') (Line: 16)
Drupal\Core\Plugin\Factory\ContainerFactory->createInstance('', Array) (Line: 83)
Drupal\Component\Plugin\PluginManagerBase->createInstance('', Array) (Line: 17)
Drupal\symfony_mailer\Processor\AdjusterPluginCollection->initializePlugin('') (Line: 80)
Drupal\Component\Plugin\LazyPluginCollection->get('') (Line: 160)
Drupal\Core\Plugin\DefaultLazyPluginCollection->setInstanceConfiguration('', Array) (Line: 135)
Drupal\Core\Plugin\DefaultLazyPluginCollection->setConfiguration(Array) (Line: 26)
Drupal\symfony_mailer\Form\PolicyEditForm->form(Array, Object) (Line: 106)
Drupal\Core\Entity\EntityForm->buildForm(Array, Object)
call_user_func_array(Array, Array) (Line: 536)
Drupal\Core\Form\FormBuilder->retrieveForm('mailer_policy_edit_form', Object) (Line: 375)
Drupal\Core\Form\FormBuilder->rebuildForm('mailer_policy_edit_form', Object, Array) (Line: 633)
Drupal\Core\Form\FormBuilder->processForm('mailer_policy_edit_form', Array, Object) (Line: 325)
Drupal\Core\Form\FormBuilder->buildForm(Object, Object) (Line: 73)
Drupal\Core\Controller\FormController->getContentResult(Object, Object)
call_user_func_array(Array, Array) (Line: 123)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}() (Line: 580)
Drupal\Core\Render\Renderer->executeInRenderContext(Object, Object) (Line: 124)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->wrapControllerExecutionInRenderContext(Array, Array) (Line: 97)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}() (Line: 169)
Symfony\Component\HttpKernel\HttpKernel->handleRaw(Object, 1) (Line: 81)
Symfony\Component\HttpKernel\HttpKernel->handle(Object, 1, 1) (Line: 44)
Drupal\redirect_after_login\RedirectMiddleware->handle(Object, 1, 1) (Line: 58)
Drupal\Core\StackMiddleware\Session->handle(Object, 1, 1) (Line: 48)
Drupal\Core\StackMiddleware\KernelPreHandle->handle(Object, 1, 1) (Line: 106)
Drupal\page_cache\StackMiddleware\PageCache->pass(Object, 1, 1) (Line: 85)
Drupal\page_cache\StackMiddleware\PageCache->handle(Object, 1, 1) (Line: 49)
Asm89\Stack\Cors->handle(Object, 1, 1) (Line: 48)
Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle(Object, 1, 1) (Line: 51)
Drupal\Core\StackMiddleware\NegotiationMiddleware->handle(Object, 1, 1) (Line: 23)
Stack\StackedHttpKernel->handle(Object, 1, 1) (Line: 718)
Drupal\Core\DrupalKernel->handle(Object) (Line: 19)

Steps to reproduce

  1. Go to /admin/config/system/mailer and add a new Policy, After selecting Type and adding Sub-Type it will redirect to Policy edit form.
  2. Select any element and press "Add Element".
  3. Add element details and press Save on the form.

Please see the video

https://drive.google.com/file/d/1qHwrg8Kub8tGWLzb_3y2DPXHBBv9b_-6/view?usp=sharing.

Proposed resolution

I guess that the #empty_value is causing that error since it is producing empty value for configs (but I am not sure, needs to be verified).

$form['add_actions']['add_select'] = [
  '#type' => 'select',
  '#options' => $options,
  '#empty_value' => '',
  '#empty_option' => $this->t('- Select element to add -'),
];
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

Alen Simonyan created an issue. See original summary.

alen simonyan’s picture

Issue summary: View changes
adamps’s picture

Priority: Critical » Normal
Status: Needs work » Postponed (maintainer needs more info)

It works for me and no one else has reported. Maybe it is related to something on your site? I suggest to test with creating policy for one of the Core modules.

alen simonyan’s picture

Hi Adam,
I also tried with one of the core modules and it behaves the same

https://drive.google.com/file/d/1X7qqCv8DMaqXBZTSUGuKdzdOqpFZPy49/view?usp=sharing

scotthreha’s picture

I just completed a Drupal 10 upgrade and I'm getting this same error when I try to add a new element to an existing policy. It worked without problems during the entire development process, but now that I've pushed the upgrade to production it fails.

Drupal\Component\Plugin\Exception\PluginNotFoundException: The "" plugin does not exist. Valid plugin IDs for Drupal\symfony_mailer\Processor\EmailAdjusterManager are: mailer_url_to_absolute, email_bcc, email_body, email_cc, mailer_default_headers, email_from, mailer_hooks, mailer_inline_css, email_plain, email_priority, email_reply_to, email_skip_sending, email_subject, email_theme, email_to, email_transport, mailer_wrap_and_convert in Drupal\Core\Plugin\DefaultPluginManager->doGetDefinition() (line 53 of /var/www/web/core/lib/Drupal/Component/Plugin/Discovery/DiscoveryTrait.php).

I should add that this is a policy for email receipts in Drupal Commerce.

andreic’s picture

StatusFileSize
new755.08 KB
new534 bytes

The problem was competing form actions. There was $form['add_actions'] as type 'action' and then $form['actions'] as type 'action.

The $name variable was always empty (attached screenshot) when clicking the Save button, hence the error in this issue.

The solution was to make $form['add_actions'] a container within the existing $form['actions'].

Patch added.

adamps’s picture

Status: Postponed (maintainer needs more info) » Needs work

Thanks. Drupal.org now uses requests instead of patches please.

andreic’s picture

Ok, done.

adamps’s picture

Please put your changes in the 3398364-the--plugin branch then create a merge request. This will cause the tests to run. Thanks.

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

atul_ghate’s picture

Status: Needs work » Needs review

I have changed patch into the MR, please review.

adamps’s picture

Status: Needs review » Needs work
StatusFileSize
new19.91 KB
new19.71 KB

Thanks. For me the result is worse than before. Before the select and button were on the same line, and now they are one below the other - see screenshots attached.

I believe that the buttons are no longer in the container because they still have $form['add_actions']. Instead it worked for me like this:

    $form['add_actions'] = [
      '#type' => 'container',
      '#weight' => -1,
      '#attributes' => ['class' => ['container-inline']],
    ];

Please can you check if that still works for you, then update the MR?

andreic’s picture

I can confirm the above in #13 works fine!

adamps’s picture

Issue tags: +Novice

Just needs a MR for the code in #13

atul_ghate’s picture

Status: Needs work » Needs review

I updated MR as per #13, Please review.

adamps’s picture

Version: 1.4.0 » 2.x-dev

It looks good to me thanks. Please can anyone else test?

We need a MR against 2.x please as that is now the dev branch. I can also commit the 1.x one afterwards as a backport.

adamps’s picture

atul_ghate’s picture

Added MR for 2.x branch.

adamps’s picture

Great thanks. Let's wait a week and see if someone will test, otherwise I can commit anyway based on #14.

divyansh.gupta’s picture

I tried replicating this issue on Drupal 10 with module version 2.x, following the steps in the issue summary, but couldn’t reproduce it. If anyone else is experiencing this, please share detailed steps to reproduce, including configuration settings, specific inputs causing the issue, and any error messages or logs. This will help in identifying whether it’s environment-specific or a broader issue.

  • adamps committed d8fc295a on 2.x authored by atul_ghate
    Issue #3398364 by andreic, atul_ghate, adamps, alen simonyan, divyansh....
adamps’s picture

Status: Needs review » Fixed

@divyansh.gupta thanks for trying to test. It seems almost random whether a site is affected so maybe we will never know the answer.

Status: Fixed » Closed (fixed)

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