Exception thrown when editing a finder
>>> [!note] Migrated issue
<!-- Drupal.org comment -->
<!-- Migrated from issue #3498926. -->
Reported by: [rupertj](https://www.drupal.org/user/549944)
Related to !1
>>>
<p>When editing a finder entity, with the responsive_preview module installed, I get an exception thrown:</p>
<blockquote><p>
Symfony\Component\Routing\Exception\RouteNotFoundException: Route "entity.finder.canonical" does not exist. in Drupal\Core\Routing\RouteProvider->getRouteByName() (line 208 of core/lib/Drupal/Core/Routing/RouteProvider.php).
</p></blockquote>
<p>This is triggered by these lines in responsive_preview:</p>
<div class="codeblock">
<pre><span style="color: #000000"><span style="color: #0000BB"><?php<br></span><span style="color: #007700">if (</span><span style="color: #0000BB">$entity</span><span style="color: #007700">-></span><span style="color: #0000BB">hasLinkTemplate</span><span style="color: #007700">(</span><span style="color: #DD0000">'canonical'</span><span style="color: #007700">)) {<br> return </span><span style="color: #0000BB">$entity</span><span style="color: #007700">-></span><span style="color: #0000BB">toUrl</span><span style="color: #007700">()-></span><span style="color: #0000BB">toString</span><span style="color: #007700">();<br>}<br></span><span style="color: #0000BB">?></span></span></pre></div>
<p>The cause is that the Finder entity declares a canonical link, but doesn't declare a view_builder handler. The lack of view_builder causes \Drupal\Core\Entity\Routing\DefaultHtmlRouteProvider::getCanonicalRoute() to not add the canonical route to the routing, and hence we get the exception thrown.</p>
<p>Taking out the canonical link template from the entity annotation fixes this.</p>
issue