Exception on Saving New Translation: UndefinedLinkTemplateException in Paragraphs with schemadotorg_jsonld Module

Created on 13 January 2024, 12 months ago
Updated 8 April 2024, 9 months ago

Problem/Motivation

When attempting to save a new translation for content containing paragraph entities, an UndefinedLinkTemplateException is encountered. The issue appears to be related to the schemadotorg_jsonld module. Temporarily disabling the module resolves the error, suggesting the problem is within this module's handling of paragraph entities.

Steps to reproduce

  1. Have a Drupal site with the schemadotorg_jsonld module enabled.
  2. Create or edit content that includes paragraph entities (e.g., a node with paragraph fields).
  3. Attempt to save a translation of this content.

Expected Result:
The translation should be saved without any errors.

Actual Result:
An error is encountered with the following message:

The website encountered an unexpected error. Try again later.

Drupal\Core\Entity\Exception\UndefinedLinkTemplateException: Cannot generate default URL because no link template 'canonical' or 'edit-form' was found for the 'paragraph' entity type in Drupal\Core\Entity\EntityBase->toUrl() (line 176 of core/lib/Drupal/Core/Entity/EntityBase.php).

schemadotorg_translation_schemadotorg_jsonld_schema_type_entity_alter(Array, Object, NULL) (Line: 545)
Drupal\Core\Extension\ModuleHandler->alter('schemadotorg_jsonld_schema_type_entity', Array, Object) (Line: 118)
Drupal\schemadotorg_jsonld\SchemaDotOrgJsonLdBuilder->buildEntity(Object) (Line: 301)
Drupal\schemadotorg_jsonld\SchemaDotOrgJsonLdBuilder->getSchemaPropertyFieldItem('WebPage', 'hasPart', Object) (Line: 231)
Drupal\schemadotorg_jsonld\SchemaDotOrgJsonLdBuilder->getSchemaPropertyFieldItems('WebPage', 'hasPart', Object) (Line: 165)
Drupal\schemadotorg_jsonld\SchemaDotOrgJsonLdBuilder->buildMappedEntity(Object) (Line: 105)
Drupal\schemadotorg_jsonld\SchemaDotOrgJsonLdBuilder->buildEntity(Object) (Line: 78)
Drupal\schemadotorg_jsonld\SchemaDotOrgJsonLdBuilder->build() (Line: 37)
schemadotorg_jsonld_page_attachments_alter(Array, NULL, NULL) (Line: 545)
Drupal\Core\Extension\ModuleHandler->alter('page_attachments', Array) (Line: 319)
Drupal\Core\Render\MainContent\HtmlRenderer->invokePageAttachmentHooks(Array) (Line: 285)
Drupal\Core\Render\MainContent\HtmlRenderer->Drupal\Core\Render\MainContent\{closure}() (Line: 627)
Drupal\Core\Render\Renderer->executeInRenderContext(Object, Object) (Line: 286)
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: 191)
Drupal\page_cache\StackMiddleware\PageCache->fetch(Object, 1, 1) (Line: 128)
Drupal\page_cache\StackMiddleware\PageCache->lookup(Object, 1, 1) (Line: 82)
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: 704)
Drupal\Core\DrupalKernel->handle(Object) (Line: 19)

Additional Information:

  • The error indicates an issue in generating a URL for paragraph entities, which typically do not have canonical or edit-form URLs.
  • The issue is not present when the schemadotorg_jsonld module is disabled.
  • Clearing the cache does not resolve the issue.

Might the fact that I created a 'Schema.org paragraph type' using 'WebContent' schema.org type (see attached screenshot) be the cause of the issue? In that case that option should not be available when creating new paragraph types.

Of course, I would like to re-enable the schemadotorg_jsonld module. Please let me know if I should remove my 'WebContent' paragraph types or if there is another way to fix the present issue. Thanks for feedback.

πŸ› Bug report
Status

Fixed

Version

1.0

Component

Code

Created by

πŸ‡°πŸ‡¬Kyrgyzstan dan_metille

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

Merge Requests

Comments & Activities

Production build 0.71.5 2024