When indexing an entity that is containing a rendered view mode results in a fatal error, when the view mode renders the breadcrumb in the template by e.g. using Twig tweak.

When running drush sapi-i you get the following error:

>  [error]  InvalidArgumentException while trying to render item entity:node/95:nl with view mode full for search index Elasticsearch: Route required in Drupal\Core\Url::fromRouteMatch() (line 159 of /vagrant/htdocs/web/core/lib/Drupal/Core/Url.php). 

Modules using:

Steps to reproduce:

  1. Create a custom node with a custom template e.g. node--page.html.twig
  2. In the custom template print the following twig statement: {{- drupal_breadcrumb() -}} (this twig function is provided by Twig Tweak.
  3. Create a Search API index.
  4. Add "Rendered item" as field in your index. As view mode, choose the view mode containing the drupal_breadcrumb() statement.
  5. Run drush sapi-i
  6. You now get the InvalidArgumentException error.
CommentFileSizeAuthor
#5 3101533-5.patch756 bytesjrockowitz
#4 3101533-4.patch719 bytesjeroent

Comments

JeroenT created an issue. See original summary.

jeroent’s picture

Issue summary: View changes
jeroent’s picture

Issue summary: View changes
jeroent’s picture

Status: Active » Needs review
StatusFileSize
new719 bytes
jrockowitz’s picture

StatusFileSize
new756 bytes

Using \Drupal::service('path.current')->getPath(); is going to be unpredictable via CLI. Instead let's make sure the route match object exists.

jrockowitz’s picture

Status: Needs review » Fixed

  • jrockowitz authored 92e2e92 on 8.x-5.x
    Issue #3101533 by JeroenT, jrockowitz: Indexing a rendered entity which...
jeroent’s picture

Thanks. Patch is working as expected.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.