Exceptions and errors on D10 site for specific form mode: supersede_datasheet

Created on 6 November 2023, about 1 year ago
Updated 5 August 2024, 4 months ago

Problem/Motivation

In module patched with πŸ“Œ Automated Drupal 10 compatibility fixes RTBC , on a Drupal 10 site, the following errors are occurring.

Getting error when going to content after enabling the module

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

Drupal\form_mode_manager\EntityTypeInfo->entityOperation(Object) (Line: 38)
form_mode_manager_entity_operation(Object)
call_user_func_array(Object, Array) (Line: 409)
Drupal\Core\Extension\ModuleHandler->Drupal\Core\Extension\{closure}(Object, 'form_mode_manager') (Line: 388)

This exception shouldn't be enough to bring down a site and this is now patched here (644e7324) as it is now a module's responsibility to catch an entity not returning a link with toUrl().

After patching that:

"Content" no longer crashes however when I go to edit node and click on form view mode different from Default I'm getting

Drupal\Component\Plugin\Exception\InvalidPluginDefinitionException: The "node" entity type did not specify a "fmm_edit_supersede_datasheet" form class. in Drupal\Core\Entity\EntityTypeManager->getFormObject() (line 207 of core/lib/Drupal/Core/Entity/EntityTypeManager.php).
Drupal\form_mode_manager\AbstractEntityFormModesFactory->getForm(Object, 'fmm_edit_supersede_datasheet') (Line: 216)
Drupal\form_mode_manager\AbstractEntityFormModesFactory->entityEdit(Object) (Line: 206)
Drupal\form_mode_manager\Controller\FormModeManagerEntityController->getEntityControllerResponse('entityEdit', Object) (Line: 170)
Drupal\form_mode_manager\Controller\FormModeManagerEntityController->entityEdit(Object)
call_user_func_array(Array, Array) (Line: 123)

Steps to reproduce

Steps to reproduce are currently unknown.

NB: A standard

  • Patch to D10 with πŸ“Œ Automated Drupal 10 compatibility fixes RTBC
  • Install "Form Mode Manager" on D10 existing site
  • View Content listing; caused 1st error above, now mitigated by catch exception
  • Edit a node using "Edit as XXXX" for any non-default mode; causes error above

Proposed resolution

  • Catch exception during operations build: here (644e7324)
  • UNKNOWN further fixes required

Remaining tasks

Determine cause of errors.

User interface changes

  • n/a

API changes

  • n/a

Data model changes

  • n/a
πŸ› Bug report
Status

Closed: works as designed

Version

2.0

Component

Code

Created by

πŸ‡¦πŸ‡ΊAustralia elc

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

Comments & Activities

  • Issue created by @elc
  • πŸ‡¦πŸ‡ΊAustralia elc

    Hi @VladimirAus,

    My current working theory is that you have another module in the site which is providing form mode integration which is pushing FMM out of the way.

    • FMM is not providing a working link to your edit-form.supersede_datasheet form - hence the first exception
    • Your site still has a link to that form - hence you still have some module stepping in to provide the route

    So, need to determine

    • How there is a form mode this module is not providing services; what module is stepping in?
    • How to detect when this is happening
    • How to get out of the way, or work with it
  • πŸ‡¦πŸ‡ΊAustralia elc

    What happens if you exclude FMM from any processing on the node form types?

    Assuming that node.supersede_datasheet is the only one causing issues, could you please turn off FMM handling for at least that mode, and probably all of those and node and see what is happening.

    This will completely remove FMM services from each node content type, but it seems you have something else in there working on it. I assume that you will continue to be able to link to and use that form mode.

    drush --input-format=yaml config:set "form_mode_manager.settings" form_modes.node.to_exclude "supersede_datasheet: supersede_datasheet"

    To add more, use an array

    drush --input-format=yaml config:set "form_mode_manager.settings" form_modes.node.to_exclude "{supersede_datasheet: supersede_datasheet,other: other}"

    That should at least stop FMM from stepping into whatever other module is working with node and then see if the functionality still exists as it is being provided by a different module.

    If not can you try to reproduce the error on a fresh start using the same modules?

  • Status changed to Closed: works as designed about 1 year ago
  • πŸ‡¦πŸ‡ΊAustralia VladimirAus Brisbane, Australia

    Seems like recents commits to πŸ“Œ Automated Drupal 10 compatibility fixes RTBC fixed the issue.

    supersede_datasheet is a new form view mode that I enabled for two content types.

  • πŸ‡¦πŸ‡ΊAustralia elc

    Nothing of substance has changed in the code which would be relevant to these errors.

    The code to cache the Drupal\Core\Entity\Exception\UndefinedLinkTemplateException when trying to call $entity->toUrl() you already tested and moved on to the next error.

    Perhaps this was all down to cached code? Missing files? Discovery cache?

    If it's working with the code from πŸ“Œ Automated Drupal 10 compatibility fixes RTBC without having changed anything your end, then this was just an aberration of switching code around. It was certainly inexplicable!

  • πŸ‡¦πŸ‡ΊAustralia VladimirAus Brisbane, Australia

    @ELC. Nope I cleaned the cache and everything as far as I'm aware.
    I can try to go back to the commit and see if it will trigger the crash again.

  • πŸ‡ΊπŸ‡ΈUnited States mlncn Minneapolis, MN, USA

    Noting that i also received a similar error; in this case it was after trying to install the examples module (as YouTube seems to have taken teh demo videos downβ€” and this is the first time i've been willing to click on a demo/tutorial video in a long time, lol) but it failed because this site manages to not have a body field:

    Configuration objects provided by form_mode_manager_examples have unmet dependencies: field.field.node.node_form_mode_example.body
    (field.storage.node.body)

    However, Form Mode Manager itself *did* get installed. Maybe not fully though?

    In my case, uninstalling form_mode_manager and installing it again (no example or submodules) worked. Maybe a simple cache clear would have worked too; maybe that's the only thing the initial install choking on the examples module missed.

    Putting this here for anyone else searching for this error:

    The website encountered an unexpected error. Try again later.

    Drupal\Component\Plugin\Exception\InvalidPluginDefinitionException: The "node" entity type did not specify a "fmm_application_forms" form class. in Drupal\Core\Entity\EntityTypeManager->getFormObject() (line 212 of core/lib/Drupal/Core/Entity/EntityTypeManager.php).

    Drupal\form_mode_manager\AbstractEntityFormModesFactory->getForm(Object, 'fmm_application_forms') (Line: 202)
    Drupal\form_mode_manager\AbstractEntityFormModesFactory->entityAdd(Object) (Line: 206)
    Drupal\form_mode_manager\Controller\FormModeManagerEntityController->getEntityControllerResponse('entityAdd', Object) (Line: 163)
    Drupal\form_mode_manager\Controller\FormModeManagerEntityController->entityAdd(Object)
    call_user_func_array(Array, Array) (Line: 123)
    Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}() (Line: 638)
    Drupal\Core\Render\Renderer->executeInRenderContext(Object, Object) (Line: 121)
    Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->wrapControllerExecutionInRenderContext(Array, Array) (Line: 97)
    Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}() (Line: 181)
    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)

Production build 0.71.5 2024