EntityAutocompleteTagify: Error when entity reference points to a deleted entity
>>> [!note] Migrated issue
<!-- Drupal.org comment -->
<!-- Migrated from issue #3548053. -->
Reported by: [norbert-goco](https://www.drupal.org/user/3643231)
Related to !184
>>>
<h3 id="summary-problem-motivation">Problem/Motivation</h3>
<p>When using the EntityAutocompleteTagify element, if there is an entity reference to a content entity that has been deleted, the following error occurs:</p>
<pre>TypeError: Drupal\Core\Entity\EntityRepository::getTranslationFromContext(): <br>Argument #1 ($entity) must be of type Drupal\Core\Entity\EntityInterface, null given, <br>called in /var/www/html/public_html/modules/contrib/tagify/src/Element/EntityAutocompleteTagify.php on line 247 <br>in Drupal\Core\Entity\EntityRepository->getTranslationFromContext() <br>(/var/www/html/public_html/core/lib/Drupal/Core/Entity/EntityRepository.php line 94).</pre><h4 id="summary-steps-reproduce">Steps to reproduce</h4>
<p> 1. Create an entity reference field that uses the Tagify autocomplete widget.<br>
2. Reference a content entity (e.g., a node).<br>
3. Delete the referenced content entity.<br>
4. Edit the referencing entity.</p>
<p>Actual result:<br>
A fatal error is thrown because getTranslationFromContext() receives null instead of an EntityInterface.</p>
<p>Expected result:<br>
The widget should handle missing/deleted entities gracefully (e.g., skip them or show a placeholder), without throwing a fatal error.</p>
issue