[error] Drupal\Component\Plugin\Exception\ContextException: The context is not a valid context.

Created on 29 July 2022, over 2 years ago
Updated 11 September 2024, 2 months ago

Problem/Motivation

After updating ctools to the latest version (3.10 OR 4.0.1), editing any content type page (with pathauto configured) results in the following error (per #3300682-05: [error] Drupal\Component\Plugin\Exception\ContextException: The context is not a valid context. :

[error] Drupal\Component\Plugin\Exception\ContextException: The context is not a valid context. in Drupal\Core\Executable\ExecutablePluginBase->getContextDefinition() (line 184 of docroot/core/lib/Drupal/Core/Plugin/ContextAwarePluginTrait.php).

As a friendly note from #3300682-41: [error] Drupal\Component\Plugin\Exception\ContextException: The context is not a valid context. :

Reminder: If your site broke now, it would have broken in D10 even without this problem. You might have the same problem with core block config definitions if you use node type conditions, double-check block.* files as well and adjust accordingly.

Steps to reproduce

Enable drupal/pathauto and have at least one pattern defined that uses content type as a context (checkbox in pattern config page).

Proposed resolution

Per #3300682-39: [error] Drupal\Component\Plugin\Exception\ContextException: The context is not a valid context. :

To fix your site so that it can use the latest CTools, search your site's configuration for "node_type" in the pathauto.*.yml files and replace it with 'entity_bundle:node'; alternatively just rerun pathauto_update_8108() (or copy its contents to your own custom module) and re-export the settings.

Per #3300682-41: [error] Drupal\Component\Plugin\Exception\ContextException: The context is not a valid context. :

I have now also released pathauto 8.x-1.11, which no longer depends on ctools, so if you are not using ctools otherwise, you can uninstall it now.

Note that there is a difference between default configuration in modules/install profiles (which must be updated manually) and the config sync folder of a specific site. the live config of a site _MUST_ always be re-exported after running updates*. Not doing so will cause many other problem as well and has caused problems in the past.

And #3300682-43: [error] Drupal\Component\Plugin\Exception\ContextException: The context is not a valid context. :

And yes, repeating myself again as well for extra clarity for everyone who ends up here (context is #39, see instructions there or if you maintain a module/distribution with pathauto default config, see the referenced varbase issues and related discussion in 💬 PluginNotFoundException: The "node_type" plugin does not exist Fixed .

Remaining tasks

Review and test the patch in #3300682-50: [error] Drupal\Component\Plugin\Exception\ContextException: The context is not a valid context. .

🐛 Bug report
Status

Fixed

Version

3.0

Component

Code

Created by

🇮🇳India rajeshreeputra Pune

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