Route "entity.backup_migrate_settings.canonical" error

Created on 7 February 2024, about 1 year ago

Problem/Motivation

Steps to reproduce

Proposed resolution

Remaining tasks

User interface changes

API changes

Data model changes

๐Ÿ› Bug report
Status

Needs work

Version

5.0

Component

Code

Created by

๐Ÿ‡ฏ๐Ÿ‡ตJapan Skyyade

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

Merge Requests

Comments & Activities

  • Issue created by @Skyyade
  • ๐Ÿ‡ญ๐Ÿ‡บHungary Grabby

    I am getting the following also with 5.0.3 and D10.2.5 and PHP 8.2.17:

    Symfony\Component\Routing\Exception\RouteNotFoundException: Route "entity.backup_migrate_settings.canonical" does not exist. in Drupal\Core\Routing\RouteProvider->getRouteByName() (line 206 of core\lib\Drupal\Core\Routing\RouteProvider.php).

  • Status changed to Postponed: needs info 11 months ago
  • ๐Ÿ‡ฎ๐Ÿ‡ณIndia samit.310@gmail.com

    I tried to reproduced it with 5.0.3 and D10.2.5 and PHP 8.2, and it is working as expected.

    I also searched entity.backup_migrate_settings.canonical in the code base of Backup and Migrate module, but it is not exists in anywhere.

    Can you guys please reconfirm your versions?

    Thanks
    Samit K.

  • ๐Ÿ‡ฌ๐Ÿ‡งUnited Kingdom mnsmithuk

    I've upgraded from Drupal 9.5.11 to Drupal 10.2.7 and have just ran into this problem when editing a Settings Profile that I just created and also old ones.

    Drupal Version
    10.2.7

    Web Server
    Apache

    PHP
    Version
    8.2.20

    Database
    Version
    MariaDB 10.6.15

    The website encountered an unexpected error. Try again later.

    Symfony\Component\Routing\Exception\RouteNotFoundException: Route "entity.backup_migrate_settings.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.backup_migrate_settings.canonical') (Line: 276)
    Drupal\Core\Routing\UrlGenerator->generateFromRoute('entity.backup_migrate_settings.canonical', Array, Array, 1) (Line: 108)
    Drupal\Core\Render\MetadataBubblingUrlGenerator->generateFromRoute('entity.backup_migrate_settings.canonical', Array, Array, ) (Line: 765)
    Drupal\Core\Url->toString() (Line: 109)
    Drupal\responsive_preview\ResponsivePreview->getPreviewUrl() (Line: 327)
    Drupal\responsive_preview\ResponsivePreview->previewToolbar() (Line: 33)
    responsive_preview_toolbar()
    call_user_func_array(Object, Array) (Line: 409)
    Drupal\Core\Extension\ModuleHandler->Drupal\Core\Extension\{closure}(Object, 'responsive_preview') (Line: 388)
    Drupal\Core\Extension\ModuleHandler->invokeAllWith('toolbar', Object) (Line: 408)
    Drupal\Core\Extension\ModuleHandler->invokeAll('toolbar') (Line: 78)
    Drupal\toolbar\Element\Toolbar::preRenderToolbar(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: 859)
    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: 82)
    __TwigTemplate_0161ab4a723aa711874be11804be711d->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('core/themes/claro/templates/classy/layout/html.html.twig', Array) (Line: 348)
    Drupal\Core\Theme\ThemeManager->render('html', Array) (Line: 480)
    Drupal\Core\Render\Renderer->doRender(Array, ) (Line: 240)
    Drupal\Core\Render\Renderer->render(Array) (Line: 158)
    Drupal\Core\Render\MainContent\HtmlRenderer->Drupal\Core\Render\MainContent\{closure}() (Line: 627)
    Drupal\Core\Render\Renderer->executeInRenderContext(Object, Object) (Line: 153)
    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: 32)
    Drupal\big_pipe\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: 49)
    Drupal\remove_http_headers\StackMiddleware\RemoveHttpHeadersMiddleware->handle(Object, 1, 1) (Line: 51)
    Drupal\Core\StackMiddleware\StackedHttpKernel->handle(Object, 1, 1) (Line: 704)
    Drupal\Core\DrupalKernel->handle(Object) (Line: 19)

  • ๐Ÿ‡ฌ๐Ÿ‡งUnited Kingdom mnsmithuk

    should have also mentioned using Version: 5.0.3 of backup_migrate

  • First commit to issue fork.
  • ๐Ÿ‡ง๐Ÿ‡ชBelgium cedricl

    Added an empty route. This fixed the issue. Changes are in the fork.

  • Merge request !47Add empty route to fix missing route โ†’ (Open) created by cedricl
  • Open in Jenkins โ†’ Open on Drupal.org โ†’
    Core: 9.5.x + Environment: PHP 7.4 & MySQL 5.7
    last update 10 months ago
    25 pass
  • ๐Ÿ‡ญ๐Ÿ‡บHungary Grabby

    I applied the patch in the fork and Iโ€™m still getting

    The website encountered an unexpected error. Try again later.

    Symfony\Component\Routing\Exception\RouteNotFoundException: Route "entity.backup_migrate_settings.canonical" does not exist. in Drupal\Core\Routing\RouteProvider->getRouteByName() (line 208 of core\lib\Drupal\Core\Routing\RouteProvider.php).
    Drupal\Core\Routing\UrlGenerator->getRoute('entity.backup_migrate_settings.canonical') (Line: 276)
    Drupal\Core\Routing\UrlGenerator->generateFromRoute('entity.backup_migrate_settings.canonical', Array, Array, 1) (Line: 108)
    Drupal\Core\Render\MetadataBubblingUrlGenerator->generateFromRoute('entity.backup_migrate_settings.canonical', Array, Array, ) (Line: 765)
    Drupal\Core\Url->toString() (Line: 109)
    Drupal\responsive_preview\ResponsivePreview->getPreviewUrl() (Line: 327)
    Drupal\responsive_preview\ResponsivePreview->previewToolbar() (Line: 33)
    responsive_preview_toolbar()
    call_user_func_array(Object, Array) (Line: 416)
    Drupal\Core\Extension\ModuleHandler->Drupal\Core\Extension\{closure}(Object, 'responsive_preview') (Line: 395)
    Drupal\Core\Extension\ModuleHandler->invokeAllWith('toolbar', Object) (Line: 415)
    Drupal\Core\Extension\ModuleHandler->invokeAll('toolbar') (Line: 78)
    Drupal\toolbar\Element\Toolbar::preRenderToolbar(Array)
    call_user_func_array(Array, Array) (Line: 113)
    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: 870)
    Drupal\Core\Render\Renderer->doCallback('#pre_render', Array, Array) (Line: 432)
    Drupal\Core\Render\Renderer->doRender(Array) (Line: 504)
    Drupal\Core\Render\Renderer->doRender(Array, ) (Line: 248)
    Drupal\Core\Render\Renderer->render(Array) (Line: 475)
    Drupal\Core\Template\TwigExtension->escapeFilter(Object, Array, 'html', NULL, 1) (Line: 83)
    __TwigTemplate_66efd5bf41efef913ca5b0215b4df9e2->doDisplay(Array, Array) (Line: 360)
    Twig\Template->yield(Array) (Line: 335)
    Twig\Template->render(Array) (Line: 38)
    Twig\TemplateWrapper->render(Array) (Line: 33)
    twig_render_template('themes/contrib/seven/templates/classy/layout/html.html.twig', Array) (Line: 348)
    Drupal\Core\Theme\ThemeManager->render('html', Array) (Line: 491)
    Drupal\Core\Render\Renderer->doRender(Array, ) (Line: 248)
    Drupal\Core\Render\Renderer->render(Array) (Line: 158)
    Drupal\Core\Render\MainContent\HtmlRenderer->Drupal\Core\Render\MainContent\{closure}() (Line: 638)
    Drupal\Core\Render\Renderer->executeInRenderContext(Object, Object) (Line: 153)
    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: 53)
    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: 32)
    Drupal\big_pipe\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: 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: 741)
    Drupal\Core\DrupalKernel->handle(Object) (Line: 19)

    All this with D10.3.1, PHP 8.2.21, MySQL 8.0.36, Backup and Migrate 5.0.3.

  • ๐Ÿ‡น๐Ÿ‡ทTurkey rezarez

    I recently ran into this error on my Drupal site after enabling the **Backup and Migrate** module:

    Uncaught PHP Exception Symfony\Component\Routing\Exception\RouteNotFoundException: "Route "entity.backup_migrate_settings.canonical" does not exist." 
    at /var/www/html/your-site/docroot/core/lib/Drupal/Core/Routing/RouteProvider.php line 208
    

    This happened when I was trying to access some admin configuration pages, and it completely threw me off.

    #### Root Cause:
    Turns out, the route `entity.backup_migrate_settings.canonical` was missing. This is a critical route for the Backup & Migrate module, and if itโ€™s not properly registered, the module canโ€™t function as expected.

    #### How I Fixed It:

    Hereโ€™s the step-by-step approach I followed to get things working again:

    **Add the Missing Route**:
    After realizing that the error was caused by a missing route, I opened the `backup_migrate.routing.yml` file (located in `modules/contrib/backup_migrate/backup_migrate.routing.yml`) and added this snippet to define the missing route:

       entity.backup_migrate_settings.canonical:
         path: '/admin/config/development/backup_migrate/settings'
         defaults:
           _entity_form: 'backup_migrate_settings.edit'
           _title: 'Backup and Migrate Settings'
         requirements:
           _permission: 'administer site configuration'
       

    3. **Clear the Cache**:
    Donโ€™t forget to clear the cache after you make changes to the routing file! Hereโ€™s the command to do it:

       drush cr
    

    4. **Rebuild the Routes (if needed)**:
    If clearing the cache doesnโ€™t seem to fix things (which didnโ€™t happen for me, but just in case), you can rebuild the routes like this:

       drush router:rebuild
    
  • Status changed to Needs work 8 months ago
  • ๐Ÿ‡บ๐Ÿ‡ธUnited States DamienMcKenna NH, USA

    rezarez: Thank you for providing a patch to possibly fix this. Unfortunately your patch file is empty.

  • ๐Ÿ‡จ๐Ÿ‡ดColombia carma03

    Confirming the patch #11 ๐Ÿ› Route "entity.backup_migrate_settings.canonical" error Needs work worked for me on D10.3.10, PHP 8.3.14, MYSQL 8.0.40, and B&M 5.1.0 โ†’ .

    Due to the attached .patch file is empty, you alternatively can use the .diff one: `https://git.drupalcode.org/project/backup_migrate/-/merge_requests/47.diff.

    Thanks @rezarez โ†’ .

  • ๐Ÿ‡ง๐Ÿ‡ชBelgium dieterholvoet Brussels

    In my case, the issue is triggered by entity_usage_entity_presave() generating a canonical link to a backup migrate source entity being saved. The problem is that the backup_migrate_source entity type defines a canonical link template, but doesn't have view_builder and route_provider handlers, which makes it so no canonical route is generated. I'll open a MR fixing that.

  • ๐Ÿ‡ง๐Ÿ‡ชBelgium dieterholvoet Brussels
  • Status changed to Needs review about 1 month ago
  • ๐Ÿ‡ฌ๐Ÿ‡งUnited Kingdom niklp Nottingham

    I applied the patch https://git.drupalcode.org/project/backup_migrate/-/merge_requests/47.diff and performed a drush updb to get the update hook to fire, but sadly the error is still present for me :( Tried a cache rebuild after too with the same result.

  • ๐Ÿ‡ฌ๐Ÿ‡งUnited Kingdom niklp Nottingham

    After a bit of chewing the fat with some other devs, I have the following to add.

    I am informed that as the settings entity is a config entity, it does not need a canonical route, so there is no need to provide one, nor to provide a view_builder.

    As such, it seems like the solution is to remove the annotation that implies that the route is there at all, and this is borne out by testing - no errors, checked it all out, seems ok.

    Here's a patch against v5.1.0 for initial testing purposes.

  • ๐Ÿ‡ฌ๐Ÿ‡งUnited Kingdom joachim

    Yup, a config entity which is only visible as an admin form doesn't need to provide a canonical link template or a canonical route. Core's config entity types don't, for example.

  • ๐Ÿ‡ญ๐Ÿ‡บHungary Grabby

    I can confirm that #17 โ†’ works for me.

Production build 0.71.5 2024