drupal_view breaks in 10.3

Created on 25 June 2024, 6 months ago
Updated 19 September 2024, 3 months ago

I upgraded to Drupal 10.3 and in a twig template, I had the following:

{% set output = drupal_view('view_name', 'machine_name' ) %} 

{{ output }}

Which worked fine. Now I get the following error.

InvalidArgumentException: "attributes" is an invalid render array key. Value should be an array but got a object. in Drupal\Core\Render\Element::children() (line 97 of /app/web/core/lib/Drupal/Core/Render/Element.php).

I spent 5+ hours chasing this down and then finally found a new issue similar but not exactly complaining about 10.3. I downgraded to 10.2 and the issue went away.

๐Ÿ› Bug report
Status

Active

Version

3.3

Component

Code

Created by

๐Ÿ‡บ๐Ÿ‡ธUnited States couloir007

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

  • Issue created by @couloir007
  • ๐Ÿ‡ท๐Ÿ‡บRussia Chi

    This needs steps to reproduce on fresh Drupal environment.

  • ๐Ÿ‡บ๐Ÿ‡ธUnited States ashooner

    We're seeing this as well.

  • ๐Ÿ‡บ๐Ÿ‡ธUnited States samia.wyatt

    We are experiencing a similar error after upgrading from Drupal 10.2 to 10.3
    Reverting back to 10.2 solved the problem.

    InvalidArgumentException: "target_id" is an invalid render array key. Value should be an array but got a string. in Drupal\Core\Render\Element::children() (line 97 of /code/web/core/lib/Drupal/Core/Render/Element.php).
    
    #0 /code/web/core/lib/Drupal/Core/Render/Renderer.php(462): Drupal\Core\Render\Element::children(Array, true)
    #1 /code/web/core/lib/Drupal/Core/Render/Renderer.php(504): Drupal\Core\Render\Renderer->doRender(Array)
    #2 /code/web/core/lib/Drupal/Core/Render/Renderer.php(248): Drupal\Core\Render\Renderer->doRender(Array, false)
    #3 /code/web/core/lib/Drupal/Core/Template/TwigExtension.php(475): Drupal\Core\Render\Renderer->render(Array)
    #4 /tmp/rolling/live_36/twig/6685a4c29a569_page--article.html.twig_R8Xw9gdeQLYM62KDdeSMZLa6X/e2c9qnCIRohWTpZgBODJgdfgNXg20NAmVPyW9Olqp74.php(103): Drupal\Core\Template\TwigExtension->escapeFilter(Object(Drupal\Core\Template\TwigEnvironment), Array, 'html', NULL, true)
    #5 /code/vendor/twig/twig/src/Template.php(360): __TwigTemplate_16801ed8d6cd49e2eafca62f095583cd->doDisplay(Array, Array)
    #6 /code/vendor/twig/twig/src/Template.php(335): Twig\Template->yield(Array)
    #7 /code/vendor/twig/twig/src/TemplateWrapper.php(38): Twig\Template->render(Array)
    #8 /code/web/core/themes/engines/twig/twig.engine(33): Twig\TemplateWrapper->render(Array)
    #9 /code/web/core/lib/Drupal/Core/Theme/ThemeManager.php(348): twig_render_template('themes/custom/a...', Array)
    #10 /code/web/core/lib/Drupal/Core/Render/Renderer.php(491): Drupal\Core\Theme\ThemeManager->render('page', Array)
    #11 /code/web/core/lib/Drupal/Core/Render/Renderer.php(248): Drupal\Core\Render\Renderer->doRender(Array, false)
    #12 /code/web/core/lib/Drupal/Core/Template/TwigExtension.php(475): Drupal\Core\Render\Renderer->render(Array)
    #13 /tmp/rolling/live_36/twig/6685a4c29a569_html.html.twig_1el1ULN29qa5IjhF3o9Z6fREt/EoqSbUmk_qmYLhcc-LMlFZtLLOLwOuHBtn5wbvFSMnM.php(90): Drupal\Core\Template\TwigExtension->escapeFilter(Object(Drupal\Core\Template\TwigEnvironment), Array, 'html', NULL, true)
    #14 /code/vendor/twig/twig/src/Template.php(360): __TwigTemplate_912ed9957d273b25091f59f94fc068d4->doDisplay(Array, Array)
    #15 /code/vendor/twig/twig/src/Template.php(335): Twig\Template->yield(Array)
    #16 /code/vendor/twig/twig/src/TemplateWrapper.php(38): Twig\Template->render(Array)
    #17 /code/web/core/themes/engines/twig/twig.engine(33): Twig\TemplateWrapper->render(Array)
    #18 /code/web/core/lib/Drupal/Core/Theme/ThemeManager.php(348): twig_render_template('themes/custom/a...', Array)
    #19 /code/web/core/lib/Drupal/Core/Render/Renderer.php(491): Drupal\Core\Theme\ThemeManager->render('html', Array)
    #20 /code/web/core/lib/Drupal/Core/Render/Renderer.php(248): Drupal\Core\Render\Renderer->doRender(Array, false)
    #21 /code/web/core/lib/Drupal/Core/Render/MainContent/HtmlRenderer.php(158): Drupal\Core\Render\Renderer->render(Array)
    #22 /code/web/core/lib/Drupal/Core/Render/Renderer.php(638): Drupal\Core\Render\MainContent\HtmlRenderer->Drupal\Core\Render\MainContent\{closure}()
    #23 /code/web/core/lib/Drupal/Core/Render/MainContent/HtmlRenderer.php(159): Drupal\Core\Render\Renderer->executeInRenderContext(Object(Drupal\Core\Render\RenderContext), Object(Closure))
    #24 /code/web/core/lib/Drupal/Core/EventSubscriber/MainContentViewSubscriber.php(90): Drupal\Core\Render\MainContent\HtmlRenderer->renderResponse(Array, Object(Symfony\Component\HttpFoundation\Request), Object(Drupal\Core\Routing\CurrentRouteMatch))
    #25 [internal function]: Drupal\Core\EventSubscriber\MainContentViewSubscriber->onViewRenderArray(Object(Symfony\Component\HttpKernel\Event\ViewEvent), 'kernel.view', Object(Drupal\Component\EventDispatcher\ContainerAwareEventDispatcher))
    #26 /code/web/core/lib/Drupal/Component/EventDispatcher/ContainerAwareEventDispatcher.php(111): call_user_func(Array, Object(Symfony\Component\HttpKernel\Event\ViewEvent), 'kernel.view', Object(Drupal\Component\EventDispatcher\ContainerAwareEventDispatcher))
    #27 /code/vendor/symfony/http-kernel/HttpKernel.php(186): Drupal\Component\EventDispatcher\ContainerAwareEventDispatcher->dispatch(Object(Symfony\Component\HttpKernel\Event\ViewEvent), 'kernel.view')
    #28 /code/vendor/symfony/http-kernel/HttpKernel.php(76): Symfony\Component\HttpKernel\HttpKernel->handleRaw(Object(Symfony\Component\HttpFoundation\Request), 1)
    #29 /code/web/core/lib/Drupal/Core/StackMiddleware/Session.php(53): Symfony\Component\HttpKernel\HttpKernel->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
    #30 /code/web/core/lib/Drupal/Core/StackMiddleware/KernelPreHandle.php(48): Drupal\Core\StackMiddleware\Session->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
    #31 /code/web/core/lib/Drupal/Core/StackMiddleware/ContentLength.php(28): Drupal\Core\StackMiddleware\KernelPreHandle->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
    #32 /code/web/core/modules/big_pipe/src/StackMiddleware/ContentLength.php(32): Drupal\Core\StackMiddleware\ContentLength->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
    #33 /code/web/core/modules/page_cache/src/StackMiddleware/PageCache.php(191): Drupal\big_pipe\StackMiddleware\ContentLength->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
    #34 /code/web/core/modules/page_cache/src/StackMiddleware/PageCache.php(128): Drupal\page_cache\StackMiddleware\PageCache->fetch(Object(Symfony\Component\HttpFoundation\Request), 1, true)
    #35 /code/web/core/modules/page_cache/src/StackMiddleware/PageCache.php(82): Drupal\page_cache\StackMiddleware\PageCache->lookup(Object(Symfony\Component\HttpFoundation\Request), 1, true)
    #36 /code/web/core/lib/Drupal/Core/StackMiddleware/ReverseProxyMiddleware.php(48): Drupal\page_cache\StackMiddleware\PageCache->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
    #37 /code/web/core/lib/Drupal/Core/StackMiddleware/NegotiationMiddleware.php(51): Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
    #38 /code/web/core/lib/Drupal/Core/StackMiddleware/AjaxPageState.php(36): Drupal\Core\StackMiddleware\NegotiationMiddleware->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
    #39 /code/web/core/lib/Drupal/Core/StackMiddleware/StackedHttpKernel.php(51): Drupal\Core\StackMiddleware\AjaxPageState->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
    #40 /code/web/core/lib/Drupal/Core/DrupalKernel.php(741): Drupal\Core\StackMiddleware\StackedHttpKernel->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
    #41 /code/web/index.php(19): Drupal\Core\DrupalKernel->handle(Object(Symfony\Component\HttpFoundation\Request))
    #42 {main}
  • ๐Ÿ‡ซ๐Ÿ‡ทFrance brulain

    Same here.
    It only happens with a view display nested in another view display as described here: https://www.drupal.org/docs/contributed-modules/twig-tweak-2x/twig-tweak... โ†’

    It throws this error:
    TypeError : Illegal offset type dans Drupal\Core\Entity\EntityStorageBase->getFromStaticCache() (ligne 183 de /var/www/prodd10-ac2f-ec/web/core/lib/Drupal/Core/Entity/EntityStorageBase.php)

    Going back to D10.2 solved this issue.
    Best.

  • ๐Ÿ‡บ๐Ÿ‡ธUnited States seth.e.shaw

    Similar situation. We have a view with a field which we rewrite with twig in which we use the drupal_view call to another view, passing the nid. See the view config in our github repo.

    The error in the logs is

    "Twig\Error\RuntimeError: An exception has been thrown during the rendering of a template ("Illegal offset type") in "__string_template__8a3a8bd9d5a3fa1601b1f9daf579e523" at line 12. in Twig\Template->yield() (line 385 of /var/www/html/drupal/vendor/twig/twig/src/Template.php)."

    and a stack trace of

    #0 /var/www/html/drupal/vendor/twig/twig/src/Template.php(335): Twig\Template->yield()
    #1 /var/www/html/drupal/vendor/twig/twig/src/TemplateWrapper.php(38): Twig\Template->render()
    #2 /var/www/html/drupal/web/core/lib/Drupal/Core/Template/TwigEnvironment.php(234): Twig\TemplateWrapper->render()
    #3 /var/www/html/drupal/web/core/lib/Drupal/Core/Render/Element/InlineTemplate.php(54): Drupal\Core\Template\TwigEnvironment->renderInline()
    #4 [internal function]: Drupal\Core\Render\Element\InlineTemplate::preRenderInlineTemplate()
    #5 /var/www/html/drupal/web/core/lib/Drupal/Core/Security/DoTrustedCallbackTrait.php(113): call_user_func_array()
    #6 /var/www/html/drupal/web/core/lib/Drupal/Core/Render/Renderer.php(870): Drupal\Core\Render\Renderer->doTrustedCallback()
    #7 /var/www/html/drupal/web/core/lib/Drupal/Core/Render/Renderer.php(432): Drupal\Core\Render\Renderer->doCallback()
    #8 /var/www/html/drupal/web/core/lib/Drupal/Core/Render/Renderer.php(248): Drupal\Core\Render\Renderer->doRender()
    #9 /var/www/html/drupal/web/core/lib/Drupal/Core/Render/Renderer.php(165): Drupal\Core\Render\Renderer->render()
    #10 /var/www/html/drupal/web/core/lib/Drupal/Core/Render/Renderer.php(638): Drupal\Core\Render\Renderer->Drupal\Core\Render\{closure}()
    #11 /var/www/html/drupal/web/core/lib/Drupal/Core/Render/Renderer.php(166): Drupal\Core\Render\Renderer->executeInRenderContext()
    #12 /var/www/html/drupal/web/core/modules/views/src/Plugin/views/PluginBase.php(424): Drupal\Core\Render\Renderer->renderInIsolation()
    #13 /var/www/html/drupal/web/core/modules/views/src/Plugin/views/field/FieldPluginBase.php(1402): Drupal\views\Plugin\views\PluginBase->viewsTokenReplace()
    #14 /var/www/html/drupal/web/core/modules/views/src/Plugin/views/field/FieldPluginBase.php(1295): Drupal\views\Plugin\views\field\FieldPluginBase->renderAltered()
    #15 /var/www/html/drupal/web/core/modules/views/src/Plugin/views/field/FieldPluginBase.php(1230): Drupal\views\Plugin\views\field\FieldPluginBase->renderText()
    #16 /var/www/html/drupal/web/core/modules/views/views.theme.inc(238): Drupal\views\Plugin\views\field\FieldPluginBase->advancedRender()
    #17 [internal function]: template_preprocess_views_view_field()
    #18 /var/www/html/drupal/web/core/lib/Drupal/Core/Theme/ThemeManager.php(261): call_user_func_array()
    #19 /var/www/html/drupal/web/core/lib/Drupal/Core/Render/Renderer.php(491): Drupal\Core\Theme\ThemeManager->render()
    #20 /var/www/html/drupal/web/core/lib/Drupal/Core/Render/Renderer.php(248): Drupal\Core\Render\Renderer->doRender()
    #21 /var/www/html/drupal/web/core/modules/views/src/Plugin/views/field/FieldPluginBase.php(1796): Drupal\Core\Render\Renderer->render()
    #22 /var/www/html/drupal/web/core/modules/views/src/Plugin/views/style/StylePluginBase.php(767): Drupal\views\Plugin\views\field\FieldPluginBase->theme()
    #23 [internal function]: Drupal\views\Plugin\views\style\StylePluginBase->elementPreRenderRow()
    #24 /var/www/html/drupal/web/core/lib/Drupal/Core/Security/DoTrustedCallbackTrait.php(113): call_user_func_array()
    #25 /var/www/html/drupal/web/core/lib/Drupal/Core/Render/Renderer.php(870): Drupal\Core\Render\Renderer->doTrustedCallback()
    #26 /var/www/html/drupal/web/core/lib/Drupal/Core/Render/Renderer.php(432): Drupal\Core\Render\Renderer->doCallback()
    #27 /var/www/html/drupal/web/core/lib/Drupal/Core/Render/Renderer.php(248): Drupal\Core\Render\Renderer->doRender()
    #28 /var/www/html/drupal/web/core/lib/Drupal/Core/Render/Renderer.php(165): Drupal\Core\Render\Renderer->render()
    #29 /var/www/html/drupal/web/core/lib/Drupal/Core/Render/Renderer.php(638): Drupal\Core\Render\Renderer->Drupal\Core\Render\{closure}()
    #30 /var/www/html/drupal/web/core/lib/Drupal/Core/Render/Renderer.php(166): Drupal\Core\Render\Renderer->executeInRenderContext()
    #31 /var/www/html/drupal/web/core/modules/views/src/Plugin/views/style/StylePluginBase.php(709): Drupal\Core\Render\Renderer->renderInIsolation()
    #32 /var/www/html/drupal/web/core/modules/views/src/Plugin/views/style/StylePluginBase.php(572): Drupal\views\Plugin\views\style\StylePluginBase->renderFields()
    #33 /var/www/html/drupal/web/core/modules/views/src/Plugin/views/style/StylePluginBase.php(463): Drupal\views\Plugin\views\style\StylePluginBase->renderGrouping()
    #34 /var/www/html/drupal/web/core/modules/views/src/Plugin/views/display/DisplayPluginBase.php(2177): Drupal\views\Plugin\views\style\StylePluginBase->render()
    #35 /var/www/html/drupal/web/core/modules/views/src/ViewExecutable.php(1592): Drupal\views\Plugin\views\display\DisplayPluginBase->render()
    #36 /var/www/html/drupal/web/core/modules/views/src/Plugin/views/display/DisplayPluginBase.php(2467): Drupal\views\ViewExecutable->render()
    #37 /var/www/html/drupal/web/core/modules/views/src/ViewExecutable.php(1721): Drupal\views\Plugin\views\display\DisplayPluginBase->preview()
    #38 /var/www/html/drupal/web/core/modules/views_ui/src/ViewUI.php(617): Drupal\views\ViewExecutable->preview()
    #39 /var/www/html/drupal/web/core/modules/views_ui/src/ViewPreviewForm.php(63): Drupal\views_ui\ViewUI->renderPreview()
    #40 /var/www/html/drupal/web/core/lib/Drupal/Core/Entity/EntityForm.php(107): Drupal\views_ui\ViewPreviewForm->form()
    #41 /var/www/html/drupal/web/core/modules/views_ui/src/ViewFormBase.php(42): Drupal\Core\Entity\EntityForm->buildForm()
    #42 [internal function]: Drupal\views_ui\ViewFormBase->buildForm()
    #43 /var/www/html/drupal/web/core/lib/Drupal/Core/Form/FormBuilder.php(536): call_user_func_array()
    #44 /var/www/html/drupal/web/core/lib/Drupal/Core/Form/FormBuilder.php(375): Drupal\Core\Form\FormBuilder->retrieveForm()
    #45 /var/www/html/drupal/web/core/lib/Drupal/Core/Form/FormBuilder.php(633): Drupal\Core\Form\FormBuilder->rebuildForm()
    #46 /var/www/html/drupal/web/core/lib/Drupal/Core/Form/FormBuilder.php(326): Drupal\Core\Form\FormBuilder->processForm()
    #47 /var/www/html/drupal/web/core/lib/Drupal/Core/Controller/FormController.php(73): Drupal\Core\Form\FormBuilder->buildForm()
    #48 /var/www/html/drupal/web/core/modules/layout_builder/src/Controller/LayoutBuilderHtmlEntityFormController.php(39): Drupal\Core\Controller\FormController->getContentResult()
    #49 [internal function]: Drupal\layout_builder\Controller\LayoutBuilderHtmlEntityFormController->getContentResult()
    #50 /var/www/html/drupal/web/core/lib/Drupal/Core/EventSubscriber/EarlyRenderingControllerWrapperSubscriber.php(123): call_user_func_array()
    #51 /var/www/html/drupal/web/core/lib/Drupal/Core/Render/Renderer.php(638): Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}()
    #52 /var/www/html/drupal/web/core/lib/Drupal/Core/EventSubscriber/EarlyRenderingControllerWrapperSubscriber.php(124): Drupal\Core\Render\Renderer->executeInRenderContext()
    #53 /var/www/html/drupal/web/core/lib/Drupal/Core/EventSubscriber/EarlyRenderingControllerWrapperSubscriber.php(97): Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->wrapControllerExecutionInRenderContext()
    #54 /var/www/html/drupal/vendor/symfony/http-kernel/HttpKernel.php(181): Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}()
    #55 /var/www/html/drupal/vendor/symfony/http-kernel/HttpKernel.php(76): Symfony\Component\HttpKernel\HttpKernel->handleRaw()
    #56 /var/www/html/drupal/web/core/lib/Drupal/Core/StackMiddleware/Session.php(53): Symfony\Component\HttpKernel\HttpKernel->handle()
    #57 /var/www/html/drupal/web/core/lib/Drupal/Core/StackMiddleware/KernelPreHandle.php(48): Drupal\Core\StackMiddleware\Session->handle()
    #58 /var/www/html/drupal/web/core/lib/Drupal/Core/StackMiddleware/ContentLength.php(28): Drupal\Core\StackMiddleware\KernelPreHandle->handle()
    #59 /var/www/html/drupal/web/core/modules/big_pipe/src/StackMiddleware/ContentLength.php(32): Drupal\Core\StackMiddleware\ContentLength->handle()
    #60 /var/www/html/drupal/web/core/modules/page_cache/src/StackMiddleware/PageCache.php(106): Drupal\big_pipe\StackMiddleware\ContentLength->handle()
    #61 /var/www/html/drupal/web/core/modules/page_cache/src/StackMiddleware/PageCache.php(85): Drupal\page_cache\StackMiddleware\PageCache->pass()
    #62 /var/www/html/drupal/web/core/lib/Drupal/Core/StackMiddleware/ReverseProxyMiddleware.php(48): Drupal\page_cache\StackMiddleware\PageCache->handle()
    #63 /var/www/html/drupal/web/core/lib/Drupal/Core/StackMiddleware/NegotiationMiddleware.php(51): Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle()
    #64 /var/www/html/drupal/web/core/lib/Drupal/Core/StackMiddleware/AjaxPageState.php(36): Drupal\Core\StackMiddleware\NegotiationMiddleware->handle()
    #65 /var/www/html/drupal/web/core/lib/Drupal/Core/StackMiddleware/StackedHttpKernel.php(51): Drupal\Core\StackMiddleware\AjaxPageState->handle()
    #66 /var/www/html/drupal/web/core/lib/Drupal/Core/DrupalKernel.php(741): Drupal\Core\StackMiddleware\StackedHttpKernel->handle()
    #67 /var/www/html/drupal/web/index.php(19): Drupal\Core\DrupalKernel->handle()
    #68 {main}
    

    Fortunately, this bit of display is not critical, so we can pull out this call while we work on a fix, but we caught this too late to consider rolling back to 10.2.

  • ๐Ÿ‡บ๐Ÿ‡ธUnited States seth.e.shaw

    Some more debugging found that, when this crashed, EntityReferenceArgument::$value was Array ( [0] => Drupal\Core\Render\Markup Object ( [string:protected] => 162291 ) ) which the Storage Manager's loadMultiple chokes on. It will only take an array of integers or string values, e.g. Array ( [0] => 162291 ) or Array ( [0] => '162291' ).

    I wrote a Views patch that fixed the issue for me yesterday:

    diff --git a/core/modules/views/src/Plugin/views/argument/EntityReferenceArgument.php b/core/modules/views/src/Plugin/views/argument/EntityReferenceArgument.php
    index d23b9c12b0..7a407c78d2 100644
    --- a/core/modules/views/src/Plugin/views/argument/EntityReferenceArgument.php
    +++ b/core/modules/views/src/Plugin/views/argument/EntityReferenceArgument.php
    @@ -54,7 +54,7 @@ public static function create(ContainerInterface $container, array $configuratio
       public function titleQuery() {
         $titles = [];
    
    -    $entities = $this->entityTypeManager->getStorage($this->definition['target_entity_type_id'])->loadMultiple($this->value);
    +    $entities = $this->entityTypeManager->getStorage($this->definition['target_entity_type_id'])->loadMultiple(array_map(fn($id) => (int)$id, $this->value));
         foreach ($entities as $entity) {
           $titles[$entity->id()] = $this->entityRepository->getTranslationFromContext($entity)->label();
         }
    

    But while writing this up I discovered that there is actually a 7 year-old issue report on this same topic โ†’ . So, I'm not sure why it worked with 10.2 and broke with 10.3, but it does essentially the same thing, but with string values rather than integers like mine.

    However, I'm not convinced this is a problem with core Views, per-se. Is there a way we can get the "drupal_view" and "drupal_view_results" calls to properly type these values? I attempted to Twig trick of casting the value to an int by changing {{ drupal_view('display_media', 'thumbnail', nid) }} to {{ drupal_view('display_media', 'thumbnail', nid + 0) }} but it still hit EntityReferenceArgument as a Markup object.

  • ๐Ÿ‡ท๐Ÿ‡บRussia Chi

    Is there a way we can get the "drupal_view" and "drupal_view_results" calls to properly type these values?

    Those Twig functions reference corresponding Drupal core functions directly. We can create wrappers for them. However, the issue itself needs to be clearly identified. I mean we need to figure out the exact change in Drupal core that triggered this problem.

    For now you can try to escape the argument like follows.

    {{ drupal_view('display_media', 'thumbnail', nid|e) }} 
    
  • Hello,
    I have the same error,
    I have a branch that loads a view {{ drupal_view('view', 'block_1') }}
    and it gives me the following error
    InvalidArgumentException: "attributes" is an invalid render array key. Value should be an array but got an object. in Drupal\Core\Render\Element::children() (line 97 of /core/lib/Drupal/Core/Render/Element.php).

  • ๐Ÿ‡บ๐Ÿ‡ธUnited States samia.wyatt

    After spending several hours researching about the issue, I found the error was located on the page--article.html.twig template. I was duplicating a taxonomy field in the twig template when it was already rendering by the view.

    Once I removed the unnecessary code on the page--article.html.twig template, the error was resolved. (in my case the conflicting field was a taxonomy field {{ node.field_tags.value }})

    Hope this helps!

  • ๐Ÿ‡ต๐Ÿ‡ฑPoland lamp5 Rzeszow

    It is not an issue with twig_tweak nor drupal core views. The problem is caused by your views custom twig template, potentially views bootstrap grid or other.

    before:

    {% if title %}
      <h3>{{ title }}</h3>
    {% endif %}
    <div id="{{ id }}" {{ attributes.addClass(classes) }}>
        {% for row in rows %}
          <div{{ row.attributes }}>
            {{row}}
          </div>
        {% endfor %}
    </div>

    after:

    <div {{ attributes.setAttribute('id', id).addClass(classes) }}>
        {% for row in rows %}
          <div{{ row.attributes }}>
            {{- row.content -}}
          </div>
        {% endfor %}
    </div>
  • ๐Ÿ‡ซ๐Ÿ‡ทFrance brulain

    @Chi
    Thanks, it works fine after adding |e.

    @lamp5
    What do you mean? I don't use custom template for this Views display.

  • ๐Ÿ‡ต๐Ÿ‡ฑPoland lamp5 Rzeszow

    @brulain but it is possible that you use views_bootstrap module and templates from this module causes the issues in my case.

  • ๐Ÿ‡ซ๐Ÿ‡ทFrance brulain

    @lamp5
    No, I don't.

  • ๐Ÿ‡ธ๐Ÿ‡ฎSlovenia KlemenDEV

    We donโ€™t either and have same issue

  • ๐Ÿ‡จ๐Ÿ‡ดColombia julianmancera

    Hi all,

    I found a workaround for the issue, our case we use a preprocess function to set some html tag attributes within a views render array, when these attributes were rendered the object vs array error popup, next the workaround:

    $group_row_attributes = new Attribute();
        $group_row_attributes->setAttribute('class', $index == 0 ? 'nav-link active' : 'nav-link');
        $group_row_attributes->setAttribute('id', "$category_name_id-tab");
        $group_row_attributes->setAttribute('data-toggle', 'pill');
        $group_row_attributes->setAttribute('href', "#$category_name_id");
        $group_row_attributes->setAttribute('role', 'tab');
        $group_row_attributes->setAttribute('aria-controls', $category_name_id);
        $group_row_attributes->setAttribute('aria-selected', $index == 0 ? 'true' : 'false');
        $variables['rows'][$index]['attributes'] = $group_row_attributes;
        $variables['rows'][$index]['#pre_render'][] = function ($elements) {
          unset($elements['attributes']);
          return $elements;
        };
    

    So correct the issue we added the $variables['rows'][$index]['#pre_render'][] function to unset the attributes array after the preprocess function is ran in ThemeManager.php line 261 for preprocess function and the the prerender in the render service.

  • ๐Ÿ‡บ๐Ÿ‡ธUnited States sassafrass

    Having a similar issue after updating from D10.3 from D10.2. Error: InvalidArgumentException: "0" is an invalid render array key. Value should be an array but got a string. in Drupal\Core\Render\Element::children() (line 97 of /var/www/html/web/core/lib/Drupal/Core/Render/Element.php).

    Stack trace:
    #0 /var/www/html/web/core/lib/Drupal/Core/Field/FormatterBase.php(103): Drupal\Core\Render\Element::children(Array)
    #1 /var/www/html/web/core/lib/Drupal/Core/Entity/Entity/EntityViewDisplay.php(268): Drupal\Core\Field\FormatterBase->view(Object(Drupal\smart_date\Plugin\Field\FieldType\SmartDateFieldItemList), 'en')
    #2 /var/www/html/web/core/lib/Drupal/Core/Entity/EntityViewBuilder.php(340): Drupal\Core\Entity\Entity\EntityViewDisplay->buildMultiple(Array)
    #3 /var/www/html/web/core/modules/node/src/NodeViewBuilder.php(24): Drupal\Core\Entity\EntityViewBuilder->buildComponents(Array, Array, Array, 'full')
    #4 /var/www/html/web/core/lib/Drupal/Core/Entity/EntityViewBuilder.php(282): Drupal\node\NodeViewBuilder->buildComponents(Array, Array, Array, 'full')
    #5 /var/www/html/web/core/lib/Drupal/Core/Entity/EntityViewBuilder.php(239): Drupal\Core\Entity\EntityViewBuilder->buildMultiple(Array)
    #6 [internal function]: Drupal\Core\Entity\EntityViewBuilder->build(Array)
    #7 /var/www/html/web/core/lib/Drupal/Core/Security/DoTrustedCallbackTrait.php(113): call_user_func_array(Array, Array)
    #8 /var/www/html/web/core/lib/Drupal/Core/Render/Renderer.php(870): Drupal\Core\Render\Renderer->doTrustedCallback(Array, Array, 'Render #pre_ren...', 'exception', 'Drupal\\Core\\Ren...')
    #9 /var/www/html/web/core/lib/Drupal/Core/Render/Renderer.php(432): Drupal\Core\Render\Renderer->doCallback('#pre_render', Array, Array)
    #10 /var/www/html/web/core/lib/Drupal/Core/Render/Renderer.php(248): Drupal\Core\Render\Renderer->doRender(Array, false)
    #11 /var/www/html/web/core/lib/Drupal/Core/Render/MainContent/HtmlRenderer.php(238): Drupal\Core\Render\Renderer->render(Array, false)
    #12 /var/www/html/web/core/lib/Drupal/Core/Render/Renderer.php(638): Drupal\Core\Render\MainContent\HtmlRenderer->Drupal\Core\Render\MainContent\{closure}()
    #13 /var/www/html/web/core/lib/Drupal/Core/Render/MainContent/HtmlRenderer.php(239): Drupal\Core\Render\Renderer->executeInRenderContext(Object(Drupal\Core\Render\RenderContext), Object(Closure))
    #14 /var/www/html/web/core/lib/Drupal/Core/Render/MainContent/HtmlRenderer.php(128): Drupal\Core\Render\MainContent\HtmlRenderer->prepare(Array, Object(Symfony\Component\HttpFoundation\Request), Object(Drupal\Core\Routing\CurrentRouteMatch))
    #15 /var/www/html/web/core/lib/Drupal/Core/EventSubscriber/MainContentViewSubscriber.php(90): Drupal\Core\Render\MainContent\HtmlRenderer->renderResponse(Array, Object(Symfony\Component\HttpFoundation\Request), Object(Drupal\Core\Routing\CurrentRouteMatch))
    #16 [internal function]: Drupal\Core\EventSubscriber\MainContentViewSubscriber->onViewRenderArray(Object(Symfony\Component\HttpKernel\Event\ViewEvent), 'kernel.view', Object(Drupal\Component\EventDispatcher\ContainerAwareEventDispatcher))
    #17 /var/www/html/web/core/lib/Drupal/Component/EventDispatcher/ContainerAwareEventDispatcher.php(111): call_user_func(Array, Object(Symfony\Component\HttpKernel\Event\ViewEvent), 'kernel.view', Object(Drupal\Component\EventDispatcher\ContainerAwareEventDispatcher))
    #18 /var/www/html/vendor/symfony/http-kernel/HttpKernel.php(186): Drupal\Component\EventDispatcher\ContainerAwareEventDispatcher->dispatch(Object(Symfony\Component\HttpKernel\Event\ViewEvent), 'kernel.view')
    #19 /var/www/html/vendor/symfony/http-kernel/HttpKernel.php(76): Symfony\Component\HttpKernel\HttpKernel->handleRaw(Object(Symfony\Component\HttpFoundation\Request), 1)
    #20 /var/www/html/web/core/lib/Drupal/Core/StackMiddleware/Session.php(53): Symfony\Component\HttpKernel\HttpKernel->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
    #21 /var/www/html/web/core/lib/Drupal/Core/StackMiddleware/KernelPreHandle.php(48): Drupal\Core\StackMiddleware\Session->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
    #22 /var/www/html/web/core/lib/Drupal/Core/StackMiddleware/ContentLength.php(28): Drupal\Core\StackMiddleware\KernelPreHandle->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
    #23 /var/www/html/web/core/modules/big_pipe/src/StackMiddleware/ContentLength.php(32): Drupal\Core\StackMiddleware\ContentLength->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
    #24 /var/www/html/web/core/modules/page_cache/src/StackMiddleware/PageCache.php(191): Drupal\big_pipe\StackMiddleware\ContentLength->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
    #25 /var/www/html/web/core/modules/page_cache/src/StackMiddleware/PageCache.php(128): Drupal\page_cache\StackMiddleware\PageCache->fetch(Object(Symfony\Component\HttpFoundation\Request), 1, true)
    #26 /var/www/html/web/core/modules/page_cache/src/StackMiddleware/PageCache.php(82): Drupal\page_cache\StackMiddleware\PageCache->lookup(Object(Symfony\Component\HttpFoundation\Request), 1, true)
    #27 /var/www/html/web/core/lib/Drupal/Core/StackMiddleware/ReverseProxyMiddleware.php(48): Drupal\page_cache\StackMiddleware\PageCache->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
    #28 /var/www/html/web/core/lib/Drupal/Core/StackMiddleware/NegotiationMiddleware.php(51): Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
    #29 /var/www/html/web/core/lib/Drupal/Core/StackMiddleware/AjaxPageState.php(36): Drupal\Core\StackMiddleware\NegotiationMiddleware->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
    #30 /var/www/html/web/core/lib/Drupal/Core/StackMiddleware/StackedHttpKernel.php(51): Drupal\Core\StackMiddleware\AjaxPageState->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
    #31 /var/www/html/web/core/lib/Drupal/Core/DrupalKernel.php(741): Drupal\Core\StackMiddleware\StackedHttpKernel->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
    #32 /var/www/html/web/index.php(19): Drupal\Core\DrupalKernel->handle(Object(Symfony\Component\HttpFoundation\Request))
    #33 {main}

  • ๐Ÿ‡บ๐Ÿ‡ธUnited States couloir007

    I'm not certain this is a twig_tweak issue anymore. I replaced my code with PHP code and I got a similar response.

    I have this:

      {{ title_prefix }}
      {% if label %}
        <h2 class="content-list __title">{{ title }}</h2>
      {% endif %}
      {{ title_suffix }}

    and when I dump title_prefix and title_suffix:

    array:1 [โ–ผ
      "level" => "h2"
    ]

    and this is the error I get. It aslo is an issue for "attributes".

    InvalidArgumentException: "level" is an invalid render array key. Value should be an array but got a string. in Drupal\Core\Render\Element::children() (line 97 of /app/web/core/lib/Drupal/Core/Render/Element.php).

  • ๐Ÿ‡บ๐Ÿ‡ธUnited States couloir007

    This might be the same issue.

    https://www.drupal.org/project/adaptivetheme/issues/3460269 ๐Ÿ› Error after updating to Drupal 10.3.1 Active

  • ๐Ÿ‡บ๐Ÿ‡ธUnited States couloir007

    Whether I set the view in PHP or Twig, the error is the same.

    {% set output = drupal_view('videos', machine_name ) %}

    InvalidArgumentException: "attributes" is an invalid render array key. Value should be an array but got a object. in Drupal\Core\Render\Element::children() (line 97 of /app/web/core/lib/Drupal/Core/Render/Element.php).

    Seems like rending views this way is broken.

  • ๐Ÿ‡บ๐Ÿ‡ธUnited States jwineichen

    #8 worked for me as well

  • ๐Ÿ‡ฎ๐Ÿ‡ณIndia hitesh_bhargav

    Now we need to use render function with the argument:

    {{ drupal_view('who_s_new', 'block_1', tid|render) }}
    

    This one work for me !!

  • I just found a related bug, the views that have the format of: -unformatted list- are the ones that give the error, if you change the format it is displayed.

    Any idea how to fix it?, without having to change the format and keep -unformatted list-

    ty

  • ๐Ÿ‡บ๐Ÿ‡ธUnited States couloir007

    {{ drupal_view('who_s_new', 'block_1', tid|render) }}

    I'm not sending any arguments, so wouldn't apply to my situation.

  • ๐Ÿ‡ฎ๐Ÿ‡ณIndia hitesh_bhargav

    If you are not sending any arguments then you don't need to pass that.

  • ๐Ÿ‡ฎ๐Ÿ‡ณIndia hitesh_bhargav

    If you are not sending any arguments then you don't need to pass that.

  • ๐Ÿ‡บ๐Ÿ‡ธUnited States couloir007

    I don't. I'm just saying my situation can't be solved with '|render'.

  • ๐Ÿ‡ฎ๐Ÿ‡ณIndia hitesh_bhargav

    Can you please explain in details what error are you getting exactly ?

  • ๐Ÿ‡ฎ๐Ÿ‡ณIndia sheshsharma

    I am getting the same issues after upgrade of Drupal 10.3. Anyone please help how to resolve this ?

    InvalidArgumentException
    : "attributes" is an invalid render array key. Value should be an array but got a object. in
    Drupal\Core\Render\Element::children()
    (line
    97
    of
    core/lib/Drupal/Core/Render/Element.php
    ).

    Details error:
    #0 /app/app/core/lib/Drupal/Core/Render/Renderer.php(462): Drupal\Core\Render\Element::children(Array, true)
    #1 /app/app/core/lib/Drupal/Core/Render/Renderer.php(248): Drupal\Core\Render\Renderer->doRender(Array, false)
    #2 /app/app/core/lib/Drupal/Core/Template/TwigExtension.php(475): Drupal\Core\Render\Renderer->render(Array)
    #3 /app/app/public-files/php/twig/66cd9ee994faa_field--paragraph--field-s_VcUzQjPjoKKJq3t-UJgWVnvU5/eWsKLhzJ6eSeTV_QoOsVVkxgJXbR8l_qcwZ0N427X9Q.php(47): Drupal\Core\Template\TwigExtension->escapeFilter(Object(Drupal\Core\Template\TwigEnvironment), Array, 'html', NULL, true)
    #4 /app/vendor/twig/twig/src/Template.php(360): __TwigTemplate_ff806e2b61d8901bec84f03d6145ab6e->doDisplay(Array, Array)
    #5 /app/vendor/twig/twig/src/Template.php(335): Twig\Template->yield(Array)
    #6 /app/vendor/twig/twig/src/TemplateWrapper.php(38): Twig\Template->render(Array)
    #7 /app/app/core/themes/engines/twig/twig.engine(33): Twig\TemplateWrapper->render(Array)
    #8 /app/app/core/lib/Drupal/Core/Theme/ThemeManager.php(348): twig_render_template('profiles/pfecsa...', Array)
    #9 /app/app/core/lib/Drupal/Core/Render/Renderer.php(491): Drupal\Core\Theme\ThemeManager->render('field', Array)
    #10 /app/app/core/lib/Drupal/Core/Render/Renderer.php(248): Drupal\Core\Render\Renderer->doRender(Array, false)
    #11 /app/app/core/lib/Drupal/Core/Template/TwigExtension.php(475): Drupal\Core\Render\Renderer->render(Array)
    #12 /app/app/public-files/php/twig/66cd9ee994faa_paragraph--main-banner.ht_TKrvxVhV1q_5zMGBpFJ4IiEXo/uyRu2HF5V7Dp_IrUbJCTJEVtmAthf6eioQXbdokFApA.php(83): Drupal\Core\Template\TwigExtension->escapeFilter(Object(Drupal\Core\Template\TwigEnvironment), Array, 'html', NULL, true)
    #13 /app/vendor/twig/twig/src/Template.php(430): __TwigTemplate_8ad46f430461422563eeb2a4018941b4->block_content(Array, Array)
    #14 /app/app/public-files/php/twig/66cd9ee994faa_paragraph--main-banner.ht_TKrvxVhV1q_5zMGBpFJ4IiEXo/uyRu2HF5V7Dp_IrUbJCTJEVtmAthf6eioQXbdokFApA.php(60): Twig\Template->yieldBlock('content', Array, Array)
    #15 /app/vendor/twig/twig/src/Template.php(430): __TwigTemplate_8ad46f430461422563eeb2a4018941b4->block_paragraph(Array, Array)
    #16 /app/app/public-files/php/twig/66cd9ee994faa_paragraph--main-banner.ht_TKrvxVhV1q_5zMGBpFJ4IiEXo/uyRu2HF5V7Dp_IrUbJCTJEVtmAthf6eioQXbdokFApA.php(42): Twig\Template->yieldBlock('paragraph', Array, Array)
    #17 /app/vendor/twig/twig/src/Template.php(360): __TwigTemplate_8ad46f430461422563eeb2a4018941b4->doDisplay(Array, Array)
    #18 /app/vendor/twig/twig/src/Template.php(335): Twig\Template->yield(Array)
    #19 /app/vendor/twig/twig/src/TemplateWrapper.php(38): Twig\Template->render(Array)
    #20 /app/app/core/themes/engines/twig/twig.engine(33): Twig\TemplateWrapper->render(Array)
    #21 /app/app/core/lib/Drupal/Core/Theme/ThemeManager.php(348): twig_render_template('profiles/pfecsa...', Array)
    #22 /app/app/core/lib/Drupal/Core/Render/Renderer.php(491): Drupal\Core\Theme\ThemeManager->render('paragraph', Array)
    #23 /app/app/core/lib/Drupal/Core/Render/Renderer.php(248): Drupal\Core\Render\Renderer->doRender(Array, false)
    #24 /app/app/core/lib/Drupal/Core/Template/TwigExtension.php(475): Drupal\Core\Render\Renderer->render(Array)
    #25 /app/app/public-files/php/twig/66cd9ee994faa_field.html.twig_wwGwgZv9qjOW6go_CwgQ_1hq4/D8n-otu-ZxdZGad_wOYYqu_Gi177OSWnFNA2UgB_a7E.php(45): Drupal\Core\Template\TwigExtension->escapeFilter(Object(Drupal\Core\Template\TwigEnvironment), Array, 'html', NULL, true)
    #26 /app/vendor/twig/twig/src/Template.php(360): __TwigTemplate_74c434cabee016edb53ad2a136720af9->doDisplay(Array, Array)
    #27 /app/vendor/twig/twig/src/Template.php(335): Twig\Template->yield(Array)
    #28 /app/vendor/twig/twig/src/TemplateWrapper.php(38): Twig\Template->render(Array)
    #29 /app/app/core/themes/engines/twig/twig.engine(33): Twig\TemplateWrapper->render(Array)
    #30 /app/app/core/lib/Drupal/Core/Theme/ThemeManager.php(348): twig_render_template('profiles/pfecsa...', Array)
    #31 /app/app/core/lib/Drupal/Core/Render/Renderer.php(491): Drupal\Core\Theme\ThemeManager->render('field', Array)
    #32 /app/app/core/lib/Drupal/Core/Render/Renderer.php(504): Drupal\Core\Render\Renderer->doRender(Array)
    #33 /app/app/core/lib/Drupal/Core/Render/Renderer.php(248): Drupal\Core\Render\Renderer->doRender(Array, false)
    #34 /app/app/core/lib/Drupal/Core/Template/TwigExtension.php(475): Drupal\Core\Render\Renderer->render(Array)
    #35 /app/app/public-files/php/twig/66cd9ee994faa_node.html.twig_owY0t3QXlbnQSnSazgs35m4HV/x3uzUDHDSgMybBSrOHbBStodFeeGm__VJcBCY2uYutk.php(101): Drupal\Core\Template\TwigExtension->escapeFilter(Object(Drupal\Core\Template\TwigEnvironment), Array, 'html', NULL, true)
    #36 /app/vendor/twig/twig/src/Template.php(360): __TwigTemplate_c5186cef318f5d483e47a380a8577561->doDisplay(Array, Array)
    #37 /app/vendor/twig/twig/src/Template.php(335): Twig\Template->yield(Array)
    #38 /app/vendor/twig/twig/src/TemplateWrapper.php(38): Twig\Template->render(Array)
    #39 /app/app/core/themes/engines/twig/twig.engine(33): Twig\TemplateWrapper->render(Array)
    #40 /app/app/core/lib/Drupal/Core/Theme/ThemeManager.php(348): twig_render_template('core/themes/sta...', Array)
    #41 /app/app/core/lib/Drupal/Core/Render/Renderer.php(491): Drupal\Core\Theme\ThemeManager->render('node', Array)
    #42 /app/app/core/lib/Drupal/Core/Render/Renderer.php(248): Drupal\Core\Render\Renderer->doRender(Array, false)
    #43 /app/app/core/lib/Drupal/Core/Render/MainContent/HtmlRenderer.php(238): Drupal\Core\Render\Renderer->render(Array, false)
    #44 /app/app/core/lib/Drupal/Core/Render/Renderer.php(638): Drupal\Core\Render\MainContent\HtmlRenderer->Drupal\Core\Render\MainContent\{closure}()
    #45 /app/app/core/lib/Drupal/Core/Render/MainContent/HtmlRenderer.php(231): Drupal\Core\Render\Renderer->executeInRenderContext(Object(Drupal\Core\Render\RenderContext), Object(Closure))
    #46 /app/app/core/lib/Drupal/Core/Render/MainContent/HtmlRenderer.php(128): Drupal\Core\Render\MainContent\HtmlRenderer->prepare(Array, Object(Symfony\Component\HttpFoundation\Request), Object(Drupal\Core\Routing\CurrentRouteMatch))
    #47 /app/app/core/lib/Drupal/Core/EventSubscriber/MainContentViewSubscriber.php(90): Drupal\Core\Render\MainContent\HtmlRenderer->renderResponse(Array, Object(Symfony\Component\HttpFoundation\Request), Object(Drupal\Core\Routing\CurrentRouteMatch))
    #48 [internal function]: Drupal\Core\EventSubscriber\MainContentViewSubscriber->onViewRenderArray(Object(Symfony\Component\HttpKernel\Event\ViewEvent), 'kernel.view', Object(Drupal\Component\EventDispatcher\ContainerAwareEventDispatcher))
    #49 /app/app/core/lib/Drupal/Component/EventDispatcher/ContainerAwareEventDispatcher.php(111): call_user_func(Array, Object(Symfony\Component\HttpKernel\Event\ViewEvent), 'kernel.view', Object(Drupal\Component\EventDispatcher\ContainerAwareEventDispatcher))
    #50 /app/vendor/symfony/http-kernel/HttpKernel.php(186): Drupal\Component\EventDispatcher\ContainerAwareEventDispatcher->dispatch(Object(Symfony\Component\HttpKernel\Event\ViewEvent), 'kernel.view')
    #51 /app/vendor/symfony/http-kernel/HttpKernel.php(76): Symfony\Component\HttpKernel\HttpKernel->handleRaw(Object(Symfony\Component\HttpFoundation\Request), 1)
    #52 /app/app/core/lib/Drupal/Core/StackMiddleware/Session.php(53): Symfony\Component\HttpKernel\HttpKernel->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
    #53 /app/app/core/lib/Drupal/Core/StackMiddleware/KernelPreHandle.php(48): Drupal\Core\StackMiddleware\Session->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
    #54 /app/app/core/lib/Drupal/Core/StackMiddleware/ContentLength.php(28): Drupal\Core\StackMiddleware\KernelPreHandle->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
    #55 /app/app/core/modules/page_cache/src/StackMiddleware/PageCache.php(191): Drupal\Core\StackMiddleware\ContentLength->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
    #56 /app/app/core/modules/page_cache/src/StackMiddleware/PageCache.php(128): Drupal\page_cache\StackMiddleware\PageCache->fetch(Object(Symfony\Component\HttpFoundation\Request), 1, true)
    #57 /app/app/core/modules/page_cache/src/StackMiddleware/PageCache.php(82): Drupal\page_cache\StackMiddleware\PageCache->lookup(Object(Symfony\Component\HttpFoundation\Request), 1, true)
    #58 /app/app/modules/pfizer/pfizer_security/src/PfizerSecurityMiddleware.php(71): Drupal\page_cache\StackMiddleware\PageCache->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
    #59 /app/app/core/lib/Drupal/Core/StackMiddleware/ReverseProxyMiddleware.php(48): Drupal\pfizer_security\PfizerSecurityMiddleware->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
    #60 /app/app/core/lib/Drupal/Core/StackMiddleware/NegotiationMiddleware.php(51): Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
    #61 /app/app/core/lib/Drupal/Core/StackMiddleware/AjaxPageState.php(36): Drupal\Core\StackMiddleware\NegotiationMiddleware->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
    #62 /app/app/core/lib/Drupal/Core/StackMiddleware/StackedHttpKernel.php(51): Drupal\Core\StackMiddleware\AjaxPageState->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
    #63 /app/app/core/lib/Drupal/Core/DrupalKernel.php(741): Drupal\Core\StackMiddleware\StackedHttpKernel->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
    #64 /app/app/index.php(19): Drupal\Core\DrupalKernel->handle(Object(Symfony\Component\HttpFoundation\Request))
    #65 {main}

  • ๐Ÿ‡ต๐Ÿ‡ฑPoland besek

    Guys, in my case this issue occured in the views where I was trying to use one of the fields in the title of the view. For example, view title was:

    Revisions list: {{ ['field_publication-revision_id'] }}

    After removing token from title, view started to work again. I'm not sure if it's just about the title or other places where tokens are used in the view.

    I'm assuming the way of using the token in the title was incorrect. I was trying to find out what could cause the issue and I'm wondering isn't it because of the fix in:
    https://www.drupal.org/project/drupal/issues/2684251 ๐Ÿ› Global Token Replacements is not working correctly in href Fixed

    I understand these information might be incorrect or incomplete, but maybe my case would provide some help to others who have similair issue?

  • ๐Ÿ‡บ๐Ÿ‡ธUnited States bburg Washington D.C.

    The Fix in #5 worked for me. I was rendering the entire {{ rows }} variable in my custom view twig template, and switching to rendering {{ row.attributes }} and {{ row.content }} resolved it for me. It's explained in this Stack Overflow post.

    Still not sure why upgrading to 10.3 triggers the appearance of this error though.

  • ๐Ÿ‡บ๐Ÿ‡ธUnited States caesius

    I was able to fix this by renaming a template like views-view-unformatted--block-1.html.twig to views-view--block-1.html.twig

    Doing stuff like changing {{- rows -}} to iterate over and display {{- row.content -}} instead only resulted in empty views.

  • ๐Ÿ‡ฎ๐Ÿ‡ณIndia Bhupendra_Raykhere indore mp

    I have upgraded to drupal 10.3. And I was getting error like
    "An exception has been thrown during the rendering of a template ('Illegal offset type')". So i cretead patch which is working for me.

  • ๐Ÿ‡บ๐Ÿ‡ฆUkraine nginex

    In my case it was an issue in form-element.html.twig

    instead of {{ description }} it's now

    <div{{ description.attributes }}>{{ description.content }}</div>

Production build 0.71.5 2024