Route "entity.workflow_state.canonical" error with EVA field

Created on 18 January 2024, 5 months ago
Updated 1 February 2024, 5 months ago

I have a working site using Workflow on several node bundles, that works fine. After upgrade, Workflow fails when viewing a node that uses workflow.
I did an upgrade from Drupal 10.1.7 to 10.2.1 with composer and then it breaks. Later on I tried 10.1.8 that works, Upgrade to 10.2.2 breaks.

On viewing such a node, containing an EVA field with links to the WorkState I get a WSOD with following error:

Route "entity.workflow_state.canonical" does not exist.
Drupal\Core\Routing\UrlGenerator->getRoute('entity.workflow_state.canonical') (Line: 276)

Answer:
As per comment #7: offending "submit" link , the problem is solved by removing the link using the canonical route in the EVA Field.
Please also check 📌 [Meta] Route "entity.workflow_state.canonical" does not exist Active

On viewing such a node I get a WSOD and following in Recent logs:

Symfony\Component\Routing\Exception\RouteNotFoundException: Route "entity.workflow_state.canonical" does not exist. in Drupal\Core\Routing\RouteProvider->getRouteByName() (line 206 of core/lib/Drupal/Core/Routing/RouteProvider.php).
Drupal\Core\Routing\UrlGenerator->getRoute('entity.workflow_state.canonical') (Line: 276)
Drupal\Core\Routing\UrlGenerator->generateFromRoute('entity.workflow_state.canonical', Array, Array, 1) (Line: 108)
Drupal\Core\Render\MetadataBubblingUrlGenerator->generateFromRoute('entity.workflow_state.canonical', Array, Array, 1) (Line: 765)
Drupal\Core\Url->toString(1) (Line: 183)
Drupal\Core\Utility\LinkGenerator->generate('Creatie', Object) (Line: 102)
Drupal\Core\Render\Element\Link::preRenderLink(Array)
call_user_func_array(Array, Array) (Line: 111)
Drupal\Core\Render\Renderer->doTrustedCallback(Array, Array, 'Render #pre_render callbacks must be methods of a class that implements \Drupal\Core\Security\TrustedCallbackInterface or be an anonymous function. The callback was %s. See https://www.drupal.org/node/2966725 ', 'exception', 'Drupal\Core\Render\Element\RenderCallbackInterface') (Line: 858)
Drupal\Core\Render\Renderer->doCallback('#pre_render', Array, Array) (Line: 421)
Drupal\Core\Render\Renderer->doRender(Array, ) (Line: 240)
Drupal\Core\Render\Renderer->render(Array) (Line: 939)
Drupal\views\Plugin\views\field\EntityField->render_item(0, Array) (Line: 1208)
Drupal\views\Plugin\views\field\FieldPluginBase->advancedRender(Object) (Line: 238)
template_preprocess_views_view_field(Array, 'views_view_field', Array)
call_user_func_array('template_preprocess_views_view_field', Array) (Line: 261)
Drupal\Core\Theme\ThemeManager->render('views_view_field', Array) (Line: 480)
Drupal\Core\Render\Renderer->doRender(Array, ) (Line: 240)
Drupal\Core\Render\Renderer->render(Array) (Line: 1784)
Drupal\views\Plugin\views\field\FieldPluginBase->theme(Object) (Line: 765)
Drupal\views\Plugin\views\style\StylePluginBase->elementPreRenderRow(Array)
call_user_func_array(Array, Array) (Line: 111)
Drupal\Core\Render\Renderer->doTrustedCallback(Array, Array, 'Render #pre_render callbacks must be methods of a class that implements \Drupal\Core\Security\TrustedCallbackInterface or be an anonymous function. The callback was %s. See https://www.drupal.org/node/2966725 ', 'exception', 'Drupal\Core\Render\Element\RenderCallbackInterface') (Line: 858)
Drupal\Core\Render\Renderer->doCallback('#pre_render', Array, Array) (Line: 421)
Drupal\Core\Render\Renderer->doRender(Array, ) (Line: 240)
Drupal\Core\Render\Renderer->render(Array) (Line: 704)
Drupal\views\Plugin\views\style\StylePluginBase->renderFields(Array) (Line: 570)
Drupal\views\Plugin\views\style\StylePluginBase->renderGrouping(Array, Array, 1) (Line: 461)
Drupal\views\Plugin\views\style\StylePluginBase->render(Array) (Line: 2174)
Drupal\views\Plugin\views\display\DisplayPluginBase->render() (Line: 1548)
Drupal\views\ViewExecutable->render() (Line: 378)
Drupal\eva\Plugin\views\display\Eva->execute() (Line: 1645)
Drupal\views\ViewExecutable->executeDisplay('entity_view_1', Array) (Line: 81)
Drupal\views\Element\View::preRenderViewElement(Array)
call_user_func_array(Array, Array) (Line: 111)
Drupal\Core\Render\Renderer->doTrustedCallback(Array, Array, 'Render #pre_render callbacks must be methods of a class that implements \Drupal\Core\Security\TrustedCallbackInterface or be an anonymous function. The callback was %s. See https://www.drupal.org/node/2966725 ', 'exception', 'Drupal\Core\Render\Element\RenderCallbackInterface') (Line: 858)
Drupal\Core\Render\Renderer->doCallback('#pre_render', Array, Array) (Line: 421)
Drupal\Core\Render\Renderer->doRender(Array) (Line: 493)
Drupal\Core\Render\Renderer->doRender(Array, ) (Line: 240)
Drupal\Core\Render\Renderer->render(Array) (Line: 475)
Drupal\Core\Template\TwigExtension->escapeFilter(Object, Array, 'html', NULL, 1) (Line: 98)
__TwigTemplate_2a351ed1bca3fdf71a9038693a3cae10->doDisplay(Array, Array) (Line: 394)
Twig\Template->displayWithErrorHandling(Array, Array) (Line: 367)
Twig\Template->display(Array) (Line: 379)
Twig\Template->render(Array) (Line: 38)
Twig\TemplateWrapper->render(Array) (Line: 39)
twig_render_template('modules/contrib/ds/templates/ds-2col-stacked.html.twig', Array) (Line: 348)
Drupal\Core\Theme\ThemeManager->render('ds_2col_stacked', Array) (Line: 480)
Drupal\Core\Render\Renderer->doRender(Array, ) (Line: 240)
Drupal\Core\Render\Renderer->render(Array) (Line: 475)
Drupal\Core\Template\TwigExtension->escapeFilter(Object, Array, 'html', NULL, 1) (Line: 39)
__TwigTemplate_b41425b4085aa91c3c0c4417d0bf608b->doDisplay(Array, Array) (Line: 394)
Twig\Template->displayWithErrorHandling(Array, Array) (Line: 367)
Twig\Template->display(Array) (Line: 379)
Twig\Template->render(Array) (Line: 38)
Twig\TemplateWrapper->render(Array) (Line: 39)
twig_render_template('modules/contrib/ds/templates/ds-entity-view.html.twig', Array) (Line: 348)
Drupal\Core\Theme\ThemeManager->render('ds_entity_view', Array) (Line: 480)
Drupal\Core\Render\Renderer->doRender(Array, ) (Line: 240)
Drupal\Core\Render\Renderer->render(Array, ) (Line: 238)
Drupal\Core\Render\MainContent\HtmlRenderer->Drupal\Core\Render\MainContent\{closure}() (Line: 627)
Drupal\Core\Render\Renderer->executeInRenderContext(Object, Object) (Line: 239)
Drupal\Core\Render\MainContent\HtmlRenderer->prepare(Array, Object, Object) (Line: 128)
Drupal\Core\Render\MainContent\HtmlRenderer->renderResponse(Array, Object, Object) (Line: 90)
Drupal\Core\EventSubscriber\MainContentViewSubscriber->onViewRenderArray(Object, 'kernel.view', Object)
call_user_func(Array, Object, 'kernel.view', Object) (Line: 111)
Drupal\Component\EventDispatcher\ContainerAwareEventDispatcher->dispatch(Object, 'kernel.view') (Line: 186)
Symfony\Component\HttpKernel\HttpKernel->handleRaw(Object, 1) (Line: 76)
Symfony\Component\HttpKernel\HttpKernel->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: 28)
Drupal\Core\StackMiddleware\ContentLength->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: 50)
Drupal\ban\BanMiddleware->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: 36)
Drupal\Core\StackMiddleware\AjaxPageState->handle(Object, 1, 1) (Line: 51)
Drupal\Core\StackMiddleware\StackedHttpKernel->handle(Object, 1, 1) (Line: 704)
Drupal\Core\DrupalKernel->handle(Object) (Line: 19)

I rolled back the Drupal upgrade and everything is fine again.

🐛 Bug report
Status

Closed: works as designed

Version

1.7

Component

Code

Created by

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

  • Issue created by @sboden
  • 🇩🇪Germany drubb Sindelfingen

    Just to clarify: you've upgraded Drupal core, but presumably not the D8 version. So from 10.1.7 to 10.2.1, right?

  • 🇩🇪Germany axroth Stuttgart

    > from 10.1.7 to 10.2.1, right?

    yes, that is correct. Issue persists with 10.2.2 too.

  • Yes, also correct for me. I did an upgrade from Drupal 10.1.7 to 10.2.1 with composer and then it breaks. Later on I tried 10.1.8 that works, Upgrade to 10.2.2 breaks.

    I have the problem locally in a ddev environment and also on our ECS test environment on AWS with a CI-CD flow, so the environment is always clean (no left-overs of code or so), "drush updb" is properly run, ...

    When I'm on Drupal 10.1.x and I run "drush route" entity.workflow_state.canonical is also not in the output. So my current assumption is that something in Drupal 10.2 triggers that route while it's not supposed to be triggered.

    On the node views where it breaks I have an EVA to show the workflow history.

  • 🇩🇪Germany drubb Sindelfingen

    Check the View that is rendered here, obviously. If it renders workflow states, they should NOT be linked to the workflow state entity, as workflow states don't have canonical urls.

  • I checked the EVA view involved, it looks ok to me:
    - The fields in the EVA are all fields from the Workflow category: From State, To State, ...
    - Entity content setting is type "Content", Arguments is "id".
    - It has a contextual filter "Workflow: Entity ID" which takes default value of "id in URL"

    The EVA shows the list of workflow transitions of the node it's on.

    It does work in 10.1.x, but not in 10.2.x

  • 🇩🇪Germany drubb Sindelfingen

    Did you check the columns (Views fields) 'From State' and 'To State'? There's a checkbox, something like 'Link label to the referenced entity', this MUST be unchecked!

  • #7 stops the error from occurring so that's good, thanks.

    Is there a way to make it more error-proof? Disable "something" so the link to entity option doesn't appear in views for from/to state, e.g. the Log Message and Transaction ID field just don't have that option to link to an entity. Alternatively make workflow work with the option, but I guess that wouldn't make much sense. Or a hook that scans the fields in views to switch off the option.

  • 🇩🇪Germany drubb Sindelfingen

    IMHO this is a core Views issue. Views should hide the checkbox and prevent linking to entities that don't have a canonical route / url.
    I'm not sure what has been changed from Drupal 10.1 to 10.2. Maybe this failed silently before, and now throws an error.
    I guess there's nothing Workflows or EVA can do to fix this.

  • 🇳🇱Netherlands johnv

    Are you upgrading from Drupal 10.1 to 10.2. or from Drupal 8.1 to 8.2?

    please check other issues with 'canonical'. There has been lots done in the past.
    Some modules assume it to be there, but the module Workflow does not need it.

  • 🇳🇱Netherlands johnv

    Are you upgrading from Drupal 10.1 to 10.2. or from Drupal 8.1 to 8.2?

    please check other issues with 'canonical'. There has been lots done in the past.
    Some modules assume it to be there, but the module Workflow does not need it.

  • The problems occurs when upgrading from Drupal 10.1.x to 10.2.x: it works in 10.1.7 and 10.1.8, it breaks as of 10.2.1 (I didn't try 10.2.0)

    My problem was solved with #7 above. In a view I have the "From state" and "To state" element had the checkbox on for "Link label to the referenced entity". The canonical view for workflow state never existed but in Drupal 10.1.x it gets ignored, while in Drupal 10.2.x it breaks.

    The solution is not to switch on the option "Link label to the referenced entity". Better option would be for views not to show the checkbox when the element does not have a canonical view.

  • 🇯🇴Jordan Anas_maw

    #7 solved the issue for me

  • This issue can be closed. The short term solution is as suggested in #7 not to switch on the "Link label to the referenced entity" for the workflow fields that don't have a canonical view (e.g. "From state" and "To state").

    Follow up issue at https://www.drupal.org/project/drupal/issues/3415993 "Link label to the referenced entity" changed behavior from Drupal 10.1 to 10.2 Active . It would be nicer when the "Link label to the referenced entity" would not be shown in the settings for fields that don't have a canonical view, or fail silently when displaying the view instead of getting a WSOD.

    The behaviour of this changed from 10.1.x to 10.2.x, in 10.1.x it would be silently ignored.

  • Status changed to Closed: works as designed 5 months ago
  • 🇳🇱Netherlands johnv

    As per comment #7: offending "submit" link , the problem is solved by removing the link using the canonical route in the EVA Field.
    Please also check 📌 [Meta] Route "entity.workflow_state.canonical" does not exist Active

    The link should not be generated, since it has no usage in the Workflow module.
    As a maintainer, thanks for helping eachother out.

Production build 0.69.0 2024