InvalidArgumentException: "0" is an invalid render array key

Created on 29 August 2024, 4 months ago

Hi Team,

I recently update my from 10.2.7 to 10.3.1. After this upgrade many pages on the site displaying "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 core/lib/Drupal/Core/Render/Element.php)."

Could anyone please help on this to fix this issue?

Thanks

🐛 Bug report
Status

Active

Version

10.3

Component
Other 

Last updated about 3 hours ago

Created by

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

Comments & Activities

  • Issue created by @harikumar_prft
  • Status changed to Postponed: needs info 4 months ago
  • For a bug report we need technical details which explain precisely how to reproduce the bug.

    In addition it is helpful to include a stack trace.

  • This might be related to this recent effort https://www.drupal.org/project/drupal/issues/3352256 📌 Move code from the experimental SDC module to core Fixed

    But I also see a few very related issues https://www.drupal.org/project/twig_tweak/issues/3457069 🐛 drupal_view breaks in 10.3 Active
    for Twig Tweak which I have on my site. But it also seems to be appearing elsewhere like https://www.drupal.org/project/adaptivetheme/issues/3460269 🐛 Error after updating to Drupal 10.3.1 Active which I don't use. So, it might not be limited to just twig_tweak users.

    I was able to semi-resolve my issue by identifying a lone string in a render array on the affected page and converting it to [#markup" => "the string"]. I'm still looking for some deeper explanation for this.

  • 🇫🇷France eddylbs Paris

    Hello,
    I have the same error on 10.3.1 and when donwgrade to 10.2.7 it works again.

    There is part of my code :

    $paragraphs['left_block'][] = $entityTypeManager->getViewBuilder('paragraph')->view($entityTypeManager->getStorage('paragraph')->load($paragraph_id), 'at_the_moment');
    

    Then i insert this in a render array

    $build['at_the_moment_block'] = [
              '#theme' => 'atm_block',
              '#elements' => [
                'paragraphs' => $paragraphs,
              ],
            ];
    

    "atm_block" it's my custom theme

    'atm_block' => array(
          'variables' => array('elements' => NULL),
          'template' => 'atm-block'
        ),
    

    My part of twig

    {% for paragraph in elements.paragraphs.left_block %}
                    <li class="carousel-list-item">{{ paragraph }}</li>
                {% endfor %}
    

    This works on 10.2.7 but i have the same error on 10.3.1.

    I don't understand that the problem is on the view paragraph render array.

    Thank you

  • 🇮🇳India itsbakiya

    Hello,
    I am also facing issue after upgrade to 10.3.x form 10.2.7

    Uncaught PHP Exception InvalidArgumentException: ""count" is an invalid render array key. Value should be an array but got a integer. at app\docroot\core\lib\Drupal\Core\Render\Element.php line 97.

    Any support will be helpful.

    Thank You.

  • 🇮🇳India raj.solanki

    Patch No. 17 resolved this issue for me. It should fix it for you as well.
    https://www.drupal.org/project/skeletontheme/issues/3275683#comment-1565... 🐛 User error: "0" is an invalid render array key in Drupal\Core\Render\Element::children() (line 98 of core/lib/Drupal/Core/Render/Element.php) with Drupal 9.3.9 Needs review

Production build 0.71.5 2024