Getting a InvalidComponentException on gcds:gcds-select

Created on 29 August 2025, 23 days ago

Problem/Motivation

Drupal\Core\Render\Component\Exception\InvalidComponentException: [value] Array value found, but a string, a null or an object is required in Drupal\Core\Theme\Component\ComponentValidator->validateProps() (line 206 of core/lib/Drupal/Core/Theme/Component/ComponentValidator.php).

Drupal\Core\Template\ComponentsTwigExtension->doValidateProps(Array, 'gcds:gcds-select') (Line: 110)
Drupal\Core\Template\ComponentsTwigExtension->validateProps(Array, 'gcds:gcds-select') (Line: 47)
__TwigTemplate_b49359e10ad9d57769de732f23b490b0->doDisplay(Array, Array) (Line: 388)
Twig\Template->yield(Array, Array) (Line: 130)
__TwigTemplate_29b6fa6226a6faf8c2ca4530bab1cfbd___2060047343->doDisplay(Array, Array) (Line: 388)
Twig\Template->yield(Array) (Line: 44)
__TwigTemplate_29b6fa6226a6faf8c2ca4530bab1cfbd->doDisplay(Array, Array) (Line: 388)
Twig\Template->yield(Array, Array) (Line: 344)
Twig\Template->display(Array) (Line: 359)
Twig\Template->render(Array) (Line: 51)
Twig\TemplateWrapper->render(Array) (Line: 234)
Drupal\Core\Template\TwigEnvironment->renderInline('{# inline_template_start #}{# This template was dynamically generated by single-directory components #}
{% embed 'gcds:gcds-select' %}
{% endembed %}
', Array) (Line: 54)
Drupal\Core\Render\Element\InlineTemplate::preRenderInlineTemplate(Array)
call_user_func_array(Array, Array) (Line: 113)
Drupal\Core\Render\Renderer->doTrustedCallback(Array, Array, 'Render #pre_render callbacks must be methods of a class that implements \Drupal\Core\Security\TrustedCallbackInterface or be an anonymous function. The callback was %s. See https://www.drupal.org/node/2966725 ', 'exception', 'Drupal\Core\Render\Element\RenderCallbackInterface') (Line: 886)
Drupal\Core\Render\Renderer->doCallback('#pre_render', Array, Array) (Line: 431)
Drupal\Core\Render\Renderer->doRender(Array) (Line: 503)
Drupal\Core\Render\Renderer->doRender(Array, ) (Line: 248)
Drupal\Core\Render\Renderer->render(Array) (Line: 484)
Drupal\Core\Template\TwigExtension->escapeFilter(Object, Array, 'html', NULL, 1) (Line: 47)
__TwigTemplate_13f3f3c7ab67068a34a4796625f25205->doDisplay(Array, Array) (Line: 388)
Twig\Template->yield(Array, Array) (Line: 344)
Twig\Template->display(Array) (Line: 359)
Twig\Template->render(Array) (Line: 51)
Twig\TemplateWrapper->render(Array) (Line: 33)
twig_render_template('themes/contrib/gcds/templates/form/select.html.twig', Array) (Line: 348)
Drupal\Core\Theme\ThemeManager->render('select', Array) (Line: 490)
Drupal\Core\Render\Renderer->doRender(Array) (Line: 503)
Drupal\Core\Render\Renderer->doRender(Array) (Line: 503)
Drupal\Core\Render\Renderer->doRender(Array, ) (Line: 248)
Drupal\Core\Render\Renderer->render(Array, ) (Line: 238)
Drupal\Core\Render\MainContent\HtmlRenderer->Drupal\Core\Render\MainContent\{closure}() (Line: 637)
Drupal\Core\Render\Renderer->executeInRenderContext(Object, Object) (Line: 231)
Drupal\Core\Render\MainContent\HtmlRenderer->prepare(Array, Object, Object) (Line: 128)
Drupal\Core\Render\MainContent\HtmlRenderer->renderResponse(Array, Object, Object) (Line: 90)
Drupal\Core\EventSubscriber\MainContentViewSubscriber->onViewRenderArray(Object, 'kernel.view', Object)
call_user_func(Array, Object, 'kernel.view', Object) (Line: 111)
Drupal\Component\EventDispatcher\ContainerAwareEventDispatcher->dispatch(Object, 'kernel.view') (Line: 186)
Symfony\Component\HttpKernel\HttpKernel->handleRaw(Object, 1) (Line: 76)
Symfony\Component\HttpKernel\HttpKernel->handle(Object, 1, 1) (Line: 53)
Drupal\Core\StackMiddleware\Session->handle(Object, 1, 1) (Line: 48)
Drupal\Core\StackMiddleware\KernelPreHandle->handle(Object, 1, 1) (Line: 28)
Drupal\Core\StackMiddleware\ContentLength->handle(Object, 1, 1) (Line: 32)
Drupal\big_pipe\StackMiddleware\ContentLength->handle(Object, 1, 1) (Line: 116)
Drupal\page_cache\StackMiddleware\PageCache->pass(Object, 1, 1) (Line: 90)
Drupal\page_cache\StackMiddleware\PageCache->handle(Object, 1, 1) (Line: 48)
Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle(Object, 1, 1) (Line: 51)
Drupal\Core\StackMiddleware\NegotiationMiddleware->handle(Object, 1, 1) (Line: 36)
Drupal\Core\StackMiddleware\AjaxPageState->handle(Object, 1, 1) (Line: 51)
Drupal\Core\StackMiddleware\StackedHttpKernel->handle(Object, 1, 1) (Line: 741)
Drupal\Core\DrupalKernel->handle(Object) (Line: 19)

Steps to reproduce

  1. Create a content type with a single Select field.
  2. Create a content of the new content type.
  3. After saving, the content page is displayed.
  4. Press Edit.
  5. As soon as edit is pressed, I get the fatal error.

I found the issue on a content types with a select field.

Proposed resolution

Remaining tasks

User interface changes

API changes

Data model changes

🐛 Bug report
Status

Active

Version

1.0

Component

Code

Created by

🇨🇦Canada xmacinfo Canada

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

Merge Requests

Comments & Activities

  • Issue created by @xmacinfo
  • 🇨🇦Canada Liam Morland Ontario, CA 🇨🇦

    Which property is it?

  • 🇨🇦Canada xmacinfo Canada

    I am using the barebone GCDS theme with a barebone content type using a Select field.

    Nothing custom.

    I even created a new content type from scratch with a single Select field to replicate the issue on Drupal 10.5.2.

  • 🇨🇦Canada Liam Morland Ontario, CA 🇨🇦

    To debug this, I suggest you look at gcds_preprocess_select() and comment-out each property in turn until the error goes away.

  • 🇨🇦Canada xmacinfo Canada

    I did comment out each '#props' one after the other and each time I get the same InvalidComponentException error.

    If I comment-out the whole gcds_preprocess_select(), function, the form loads without any error.

    I will continue debugging the gcds_preprocess_select() function.

  • 🇨🇦Canada xmacinfo Canada

    MR tested successfully. Please review.

  • Pipeline finished with Success
    19 days ago
    Total: 3833s
    #588330
  • 🇨🇦Canada bzaher

    I'm working on this issue with xmacinfo. Commenting to provide more information about our issue.

    The issues that we encountered, related to this message. are that select fields don't support integer values or labels. Additionally the multiple selection doesn't work with select fields, though I think that's also the case with GCDS at this point.

    The integer values and labels were listed since we used a datetime field. To reproduce, add a datetime field to a content type's form display and load the edit form. We also use integer values elsewhere where there the select fields list taxonomies.

Production build 0.71.5 2024