fix: #3402443 Return a 404 when an embedded entity can't be edited

Description

The "Edit the embedded entity" route now returns a 404 instead of a fatal error when the embedded entity can't be edited, for example because it was deleted.

Issue: https://www.drupal.org/project/entity_embed/issues/3402443

  • EditEmbeddedEntity::edit() returns a 404 when no entity has the UUID, the entity type doesn't exist or has no UUIDs, or the entity type has no edit form. It redirects with the entity's edit-form URL instead of building the route name.
  • New EditEmbeddedEntityTest covers the redirect and each 404.

Part of #3639516. #3416512 builds on this to fall back to other links for entity types without an edit form.

Testing instructions

  1. Create a node A, and embed it in node B's body with an Entity Embed button.
  2. Delete node A.
  3. Edit node B, select the embed and click its edit (cog) button. Before this change, the new tab showed an error page and "Call to a member function id() on null" was logged; now it shows "Page not found".

Remaining tasks

  • Follow-up (#3639532): the route allows access to everyone (_access: 'TRUE') and relies on the edit form's own access check.
  • Follow-up (#3639516): the CKEditor 5 edit button says "You do not have the permissions needed to edit this …" for a deleted entity.

AI disclosure

Claude Code (Claude Opus 5.5) wrote the controller change, the test and this description. I chose to return a 404 rather than redirect to the 404 page as the issue's patch did, scoped the fix to the deleted-entity case so #3416512 can handle other entity types, and ran the test locally, including checking that it fails without the fix.

🤖 Generated with Claude Code

Edited by Dave Reid

Merge request reports

Loading
Loading