AI Translate: getFileUri() on null in Drupal\media\Entity\Media->getThumbnailUri() AI translate entity reference
>>> [!note] Migrated issue <!-- Drupal.org comment --> <!-- Migrated from issue #3497182. --> Reported by: [arwillame](https://www.drupal.org/user/3726366) Related to !376 >>> <h3 id="summary-problem-motivation">Problem/Motivation</h3> <p>In some cases i get this error when triying to translate content by AI.</p> <p>Error: Call to a member function getFileUri() on null in Drupal\media\Entity\Media-&gt;getThumbnailUri() (line 262 of /var/www/html/web/core/modules/media/src/Entity/Media.php).</p> <p>This error occur with entity reference translation of media.<br> This appen when the system try to translate a media wich dont have a file related.<br> This can appen with the usage of stage_file_proxy module for example, or when you use a database locally without the files for example.</p> <p>This is is cause by the <code>$referencedEntity-&gt;save();</code> in <a href="https://www.drupal.org%20https://git.drupalcode.org/project/ai/-/blob/1.0.x/modules/ai_translate/src/Plugin/FieldTextExtractor/ReferenceFieldExtractor.php?ref_type=heads#L118">ReferenceFieldExtractor.php</a> file.</p> <p>Those are specific case, but it would be good the translation dont stops because of that.</p> <h4 id="summary-steps-reproduce">Steps to reproduce</h4> <p>Configure ai translate entity reference to translate media.<br> Get a node with a media referenced where the file is not exsting for a specific media.</p> <p>To do that, use stage_file_proxy and/or import a production database locally without the files.<br> Or also just remove the file related to the media in file system.</p> <p>Then translate this node by ai and see you got a php error.</p> <h3 id="summary-proposed-resolution">Proposed resolution</h3> <p>Catch this issue and log it as error in the logs.</p>
issue