No link template 'canonical' found for the 'paragraph' entity type

Created on 22 September 2021, about 3 years ago
Updated 30 August 2024, 3 months ago

Problem/Motivation

Drupal\Core\Entity\Exception\UndefinedLinkTemplateException: No link template 'canonical' found for the 'paragraph' entity type in Drupal\Core\Entity\EntityBase->toUrl() (line 196 of core/lib/Drupal/Core/Entity/EntityBase.php).

Steps to reproduce

Get Drupal 9 and paste this code in the first hook_page_attachments_alter you find.

\Drupal::entityTypeManager()->getStorage('paragraph')->load(1)->toUrl();

Proposed resolution

Extend the base function toUrl and add a try catch.

Remaining tasks

Apply patch and see if that works.

๐Ÿ’ฌ Support request
Status

Fixed

Version

1.15

Component

Code

Created by

๐Ÿ‡ฎ๐Ÿ‡ณIndia Kumar Rakesh

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.

  • ๐Ÿ‡บ๐Ÿ‡ธUnited States JCL324 Portland, OR

    Just got this too with Drupal 10 core, Paragraphs 8.x-1.15:

    Drupal\Core\Entity\Exception\UndefinedLinkTemplateException: No link template 'canonical' found for the 'paragraph' entity type in Drupal\Core\Entity\EntityBase->toUrl() (line 196 of core/lib/Drupal/Core/Entity/EntityBase.php).

  • ๐Ÿ‡บ๐Ÿ‡ธUnited States smethawee

    I just got this too when I updated from Drupal 9.5.2 to Drupal 9.5.4 core, Paragraphs 8.x-1.15:

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

    Drupal\Core\Entity\Exception\UndefinedLinkTemplateException: No link template 'canonical' found for the 'paragraph' entity type in Drupal\Core\Entity\EntityBase->toUrl() (line 196 of core/lib/Drupal/Core/Entity/EntityBase.php).

    How to solve this issue? I still got this.

  • ๐Ÿ‡บ๐Ÿ‡ธUnited States Greg Boggs Portland Oregon

    This patch works for us in D9.

  • ๐Ÿ‡จ๐Ÿ‡ญSwitzerland berdir Switzerland

    See #20 for example. You fix this error enabling verbose errors with backtrace, see who is incorrectly calling toUrl() on an entity without checking if it has a canonical link template. It might be comments, there is an issue referenced above, or another contrib or custom module.

  • ๐Ÿ‡ณ๐Ÿ‡ฟNew Zealand Gold 20 minutes in the future

    I'm seeing this on Paragraphs 1.15.

    The site is a build with no custom code touching this area. The error is resolved with the rerolled patch at #17 is working for me. @akhilavnair, the only tweak I'd suggest is code standards on the comment.

    Given there are many reports of this being resolved by fixing it in Paragraphs I'm unsure why this isn't just being resolved here.

    It works. Using the patch at #17 with cwegans/composer-patches for now.

  • ๐Ÿ‡บ๐Ÿ‡ฆUkraine Dishvola

    In my case I need a view of the all webform submissions with a links to source entity and it's a paragraph for some cases... so the system can't to get it and I see a whitescreen.

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

    got this problem again in my drupal 9, after upgrade the core to 10, the problem stay exist

    https://www.drupal.org/project/paragraphs/issues/3404000 ๐Ÿ› The website encountered an unexpected error. ( problem with layout builder ) Active

  • First commit to issue fork.
  • ๐Ÿ‡จ๐Ÿ‡ฆCanada Liam Morland Ontario, CA ๐Ÿ‡จ๐Ÿ‡ฆ

    Liam Morland โ†’ made their first commit to this issueโ€™s fork.

  • Pipeline finished with Success
    4 months ago
    Total: 437s
    #248161
  • Pipeline finished with Failed
    4 months ago
    Total: 473s
    #248160
  • ๐Ÿ‡บ๐Ÿ‡ธUnited States andysipple

    #17 was no longer applying for me.
    Reroll #17

  • ๐Ÿ‡ณ๐Ÿ‡ฟNew Zealand Gold 20 minutes in the future

    Rerolled patch at #35 applies and still works as expected.

    Cheers @andysipple.

Production build 0.71.5 2024