I've run in to a major issue with Pathauto where as soon as you try and add in a new Pattern that only targets a specific content type, it throws the following error:

The website encountered an unexpected error. Please try again later.

Drupal\Component\Plugin\Exception\PluginNotFoundException: The "node_type" plugin does not exist. in Drupal\Core\Plugin\DefaultPluginManager->doGetDefinition() (line 52 of core/lib/Drupal/Component/Plugin/Discovery/DiscoveryTrait.php).

Digging around I found a somewhat related isse over on Ctools: https://www.drupal.org/project/ctools/issues/2638380
But I'm using a much newer version of the module so I wouldn't think it would be the cause of this issue.

Setup:
* Drupal 8.39
* PathAuto 1.0+3-dev
* CTools 8.3
* Token 1.0

And according to the release notes, required should be:
ctools 8.x-3.0
token 8.x-1.0

so we should be right.

Steps to reproduce

* Create a new Pattern via /admin/config/search/path/patterns
* Make the Pattern Type = "Content"
* Set whatever settings and titles you want and select just one content type for it to apply to
* Try and save the pattern
* See error message, changes to the pattern are not saved

Issue fork pathauto-2925169

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:

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

marblegravy created an issue. See original summary.

marblegravy’s picture

Status: Active » Postponed (maintainer needs more info)

More testing has shown that this is a conflict with another module somewhere in the mix.

Installing a fresh site with only PathAuto, Ctools and Token does not replicate the issue.

More digging required. If anyone has any ideas though I'd be happy to hear them!

daniel_j’s picture

Upstream CTools has removed the node_type plugin, and replaced it with derivatives of entity_bundle. If you export your config, you can search-and-replace on all your pathauto.pattern.*.yml, changing references to node_type to entity_bundle.node.

See https://www.drupal.org/project/ctools/issues/3300682

Berdir’s picture

There is an update function for these, but an update can only deal with existing config on existing sites, it can't fix default content in modules and install profiles.

This is the pathauto version of https://www.drupal.org/node/2983299. Help to create a custom change record for pathauto would be welcome.

Note that there is an awkward grey area for install profiles that already updated to the pathauto version that includes the update function but did not update their default content at the same time, because for these sites, that update did not run. In that case, you want to copy pathauto_update_8108() into your install profile so it runs again (with your own name and update number of course).

Berdir’s picture

Also, note that the original issue was from 2017 here, which I can't see how that's the same issue.

Berdir’s picture

And second note, I don't quite understand why the ctools update caused this. node_type is provided by core, ctools just extend it, it should not cause it to be removed entirely.

daniel_j’s picture

@Berdir, regarding your remark in #7: After the ctools update a derived plugin class is substituted for core's non-derived node_type plugin. As a result, core sees that it implements the derived interface and attempts to get the derivative ID from the plugin ID, and since it does not contain a colon, returns NULL.

Prior to CTools 3.10, it simply used the core class, and did not substitute the derived class.

Rajab Natshah’s picture

Thank you, Sascha for the hint <3 about updating profiles with pathauto_update_8108
Recalling its content after updating the default configs.
To make sure that the change of active config will not be missed.

DamienMcKenna’s picture

This could be fixed by cloning pathauto_update_8108() and adding a message instructing site maintainers to export the configuration after the changes run.

Berdir’s picture

Category: Bug report » Support request
Status: Postponed (maintainer needs more info) » Fixed

Changing to a fixed support request. The ctools bug is being fixed in the ctools issue, see also https://www.drupal.org/project/pathauto/releases/8.x-1.11.

Webbeh’s picture

Documenting this from the ctools issue:
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 #2925169: PluginNotFoundException: The "node_type" plugin does not exist.

Status: Fixed » Closed (fixed)

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

alexandersluiter’s picture

#12 Just saved me. Thank you!

JeffC518’s picture

I looked at @daniel_j's comment first (#3) which was spot on, except for one minor thing:

you can search-and-replace on all your pathauto.pattern.*.yml, changing references to node_type to entity_bundle.node.

It should be entity_bundle:node

Per example, in a pathauto.pattern.page_by_menu.yml, mine was:

pattern: '[node:menu-link:parent]/[node:title]'
selection_criteria:
  511dc248-86a2-425b-bb21-90da8d45e2d1:
    id: node_type
    bundles:
      contact_page: contact_page

but should be:

pattern: '[node:menu-link:parent]/[node:title]'
selection_criteria:
  511dc248-86a2-425b-bb21-90da8d45e2d1:
    id: entity_bundle:node
    bundles:
      contact_page: contact_page

.. assuming it's a node of course.

loopy1492’s picture

Thank you so much @JeffC518!!!!

This cropped up during our Drupal 10 upgrade.

We run `blt install:drupal` during ci build on the server and when it tried importing these into a fresh database, it choked and died with the OP's error. Changing the slection_criteria id to entity_bundle:node solved it.

coaston’s picture

Hi,

Where exactly is has to be changed ? I dont see any pathauto.pattern.* yaml files with already mentioned code :

pattern: '[node:menu-link:parent]/[node:title]'
selection_criteria:
  511dc248-86a2-425b-bb21-90da8d45e2d1:
    id: node_type
    bundles:
      contact_page: contact_page

Does not wotk for d10

coaston’s picture

Edit . It works now. I had to change it in different module, Not here in pathauto.

gshreeGS’s picture

Hi @coaston, which module did you change it in? I'm facing a similar thing

coaston’s picture

Hi gshreeGs

in my case it was triggered by different module View Mode Page and this fix resolved it :3300706

However it is connected somehow with CTools as described in #12 so the best way for you is to go to Admin > extend > Chaos Tools and see which of your contrib modules use it (Required by:) and I am sure that one of this modules have to be updated as they are not ready for D10.

fadonascimento’s picture

Thanks @Webbeh #12 Helps me a lot!

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

javitan’s picture

For some reason the after upgrading the core and module it didn't update my pattern files, so you will need to change them manually (pathauto.pattern.YOURNODE.yml).

So just change the id from this:

selection_criteria:
  xxxxxxxxxxxxxxx:
    id: node_type

Into this:

selection_criteria:
  xxxxxxxxxxxxxxx:
    id: 'entity_bundle:node'

It fixed the problem for me. Good luck!

othmen’s picture

Thanks @javitan.

#23 resolved my problem.

earthangelconsulting’s picture

#23 worked for me too. thanks!

ThirstySix’s picture

after update, it works well.

config sync file: pathauto.pattern.workshop.yml
from
id: node_type
to
id: entity_bundle:node

run drush cim
solved! Thanks #23