Preparing content for a notification can easily fail
>>> [!note] Migrated issue
<!-- Drupal.org comment -->
<!-- Migrated from issue #3484146. -->
Reported by: [jurgenhaas](https://www.drupal.org/user/168924)
Related to !14
>>>
<h3 id="summary-problem-motivation">Problem/Motivation</h3>
<p>We do get alerts that are triggered by a different exception, but regularly lead to a follow-up exception that's caused by the push framework.</p>
<p>The exception we see is something like this:</p>
<pre>CRITICAL: Site notification: Site: ... some exception fragment ..., Entity can not be rendered: The "node" entity cannot have a URI as it does not have an ID</pre><p>The real exception, that we're interested in is <code> ... some exception fragment ...</code>, but we don't get all the required details, as the follow-up exception is this: <code>Entity can not be rendered: The "node" entity cannot have a URI as it does not have an ID</code></p>
<p>This comes from <code>\Drupal\push_framework\ChannelBase::prepareContent</code> and here is what happens:</p>
<p>Whatever the original exception is, the process goes into this method to prepare the content for the notification. That method receives the <code>$entity</code> which contains the content of the notification. And that entity needs to be rendered in order to provide the real content with replaced tokens, etc.</p>
<p>Now, that entity is not an entity that's stored in the database, it's just an entity that exists in memory but hasn't been saved. And therefore, it doesn't have an ID yet. Now, the problem is, that one of the many steps in the try/catch clause wants to create a URI for that entity which throws an exception because the entity doesn't have an ID.</p>
<p>I don't know what the best way to resolve this should be. Giving that entity an ID just for the sake of it? Finding out what's trying to generate the URI and prevent that from happening? Building some other safeguards to prevent this and maybe similar issues?</p>
<p>This needs some serious thoughts, and I hope we don't have to drop that whole approach in the first place.</p>
issue