EntityAutocompleteTagify: Error when entity reference points to a deleted entity

Created on 22 September 2025, 3 months ago
Updated 25 September 2025, 2 months ago

Problem/Motivation

When using the EntityAutocompleteTagify element, if there is an entity reference to a content entity that has been deleted, the following error occurs:

TypeError: Drupal\Core\Entity\EntityRepository::getTranslationFromContext(): 
Argument #1 ($entity) must be of type Drupal\Core\Entity\EntityInterface, null given, 
called in /var/www/html/public_html/modules/contrib/tagify/src/Element/EntityAutocompleteTagify.php on line 247 
in Drupal\Core\Entity\EntityRepository->getTranslationFromContext() 
(/var/www/html/public_html/core/lib/Drupal/Core/Entity/EntityRepository.php line 94).

Steps to reproduce

1. Create an entity reference field that uses the Tagify autocomplete widget.
2. Reference a content entity (e.g., a node).
3. Delete the referenced content entity.
4. Edit the referencing entity.

Actual result:
A fatal error is thrown because getTranslationFromContext() receives null instead of an EntityInterface.

Expected result:
The widget should handle missing/deleted entities gracefully (e.g., skip them or show a placeholder), without throwing a fatal error.

πŸ› Bug report
Status

Active

Version

1.2

Component

Code

Created by

πŸ‡·πŸ‡ΈSerbia norbert-goco Subotica

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

Merge Requests

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

Production build 0.71.5 2024