TypeError: Drupal\Component\Utility\Html::escape(): Argument #1 ($text) must be of type string, null given

Created on 8 March 2025, 2 months ago
Updated 10 March 2025, 2 months ago

Problem/Motivation

I did a migration from Drupal 7 to Drupal 11, so data might not be accurate.
Cron is failing and cache is building up insanely fast.
Something with yield_amount and null being accepted as input

Stack trace is always like this:

TypeError: Drupal\Component\Utility\Html::escape(): Argument #1 ($text) must be of type string, null given, called in /home/**/public_html/core/lib/Drupal/Component/Render/FormattableMarkup.php on line 238 in Drupal\Component\Utility\Html::escape() (line 431 of /home/**/public_html/core/lib/Drupal/Component/Utility/Html.php)

#0 /home/**/public_html/core/lib/Drupal/Component/Render/FormattableMarkup.php(238): Drupal\Component\Utility\Html::escape(NULL)
#1 /home/**/public_html/core/lib/Drupal/Component/Render/FormattableMarkup.php(187): Drupal\Component\Render\FormattableMarkup::placeholderEscape(NULL)
#2 /home/**/public_html/core/lib/Drupal/Core/StringTranslation/TranslatableMarkup.php(195): Drupal\Component\Render\FormattableMarkup::placeholderFormat('@yield_amount @...', Array)
#3 /home/**/public_html/core/lib/Drupal/Component/Utility/ToStringTrait.php(15): Drupal\Core\StringTranslation\TranslatableMarkup->render()
#4 /home/**/public_html/vendor/twig/twig/src/Template.php(345): Drupal\Core\StringTranslation\TranslatableMarkup->__toString()
#5 /home/**/public_html/vendor/twig/twig/src/Template.php(359): Twig\Template->display(Array)
#6 /home/**/public_html/vendor/twig/twig/src/TemplateWrapper.php(51): Twig\Template->render(Array)
#7 /home/**/public_html/core/themes/engines/twig/twig.engine(33): Twig\TemplateWrapper->render(Array)
#8 /home/**/public_html/core/lib/Drupal/Core/Theme/ThemeManager.php(348): twig_render_template('modules/recipe/...', Array)
#9 /home/**/public_html/core/lib/Drupal/Core/Render/Renderer.php(446): Drupal\Core\Theme\ThemeManager->render('recipe_yield', Array)
#10 /home/**/public_html/core/lib/Drupal/Core/Render/Renderer.php(459): Drupal\Core\Render\Renderer->doRender(Array)
#11 /home/**/public_html/core/lib/Drupal/Core/Render/Renderer.php(203): Drupal\Core\Render\Renderer->doRender(Array, true)
#12 /home/**/public_html/core/lib/Drupal/Core/Render/Renderer.php(120): Drupal\Core\Render\Renderer->render(Array, true)
#13 /home/**/public_html/core/lib/Drupal/Core/Render/Renderer.php(593): Drupal\Core\Render\Renderer->{closure:Drupal\Core\Render\Renderer::renderInIsolation():119}()
#14 /home/**/public_html/core/lib/Drupal/Core/Render/Renderer.php(119): Drupal\Core\Render\Renderer->executeInRenderContext(Object(Drupal\Core\Render\RenderContext), Object(Closure))
#15 /home/**/public_html/core/modules/node/src/Plugin/Search/NodeSearch.php(526): Drupal\Core\Render\Renderer->renderInIsolation(Array)
#16 /home/**/public_html/core/modules/node/src/Plugin/Search/NodeSearch.php(490): Drupal\node\Plugin\Search\NodeSearch->indexNode(Object(Drupal\node\Entity\Node))
#17 /home/**/public_html/core/modules/search/src/Hook/SearchHooks.php(100): Drupal\node\Plugin\Search\NodeSearch->updateIndex()
#18 /home/**/public_html/core/lib/Drupal/Core/Cron.php(275): Drupal\search\Hook\SearchHooks->cron()
#19 /home/**/public_html/core/lib/Drupal/Core/Extension/ModuleHandler.php(307): Drupal\Core\Cron->{closure:Drupal\Core\Cron::invokeCronHandlers():258}(Array, 'search')
#20 /home/**/public_html/core/lib/Drupal/Core/Cron.php(258): Drupal\Core\Extension\ModuleHandler->invokeAllWith('cron', Object(Closure))
#21 /home/**/public_html/core/lib/Drupal/Core/Cron.php(97): Drupal\Core\Cron->invokeCronHandlers()
#22 /home/**/public_html/core/lib/Drupal/Core/ProxyClass/Cron.php(75): Drupal\Core\Cron->run()
#23 /home/**/public_html/core/modules/automated_cron/src/EventSubscriber/AutomatedCron.php(65): Drupal\Core\ProxyClass\Cron->run()
#24 /home/**/public_html/vendor/symfony/event-dispatcher/EventDispatcher.php(246): Drupal\automated_cron\EventSubscriber\AutomatedCron->onTerminate(Object(Symfony\Component\HttpKernel\Event\TerminateEvent), 'kernel.terminat...', Object(Symfony\Component\EventDispatcher\EventDispatcher))
#25 /home/**/public_html/vendor/symfony/event-dispatcher/EventDispatcher.php(206): Symfony\Component\EventDispatcher\EventDispatcher::{closure:Symfony\Component\EventDispatcher\EventDispatcher::optimizeListeners():241}(Object(Symfony\Component\HttpKernel\Event\TerminateEvent), 'kernel.terminat...', Object(Symfony\Component\EventDispatcher\EventDispatcher))
#26 /home/**/public_html/vendor/symfony/event-dispatcher/EventDispatcher.php(56): Symfony\Component\EventDispatcher\EventDispatcher->callListeners(Array, 'kernel.terminat...', Object(Symfony\Component\HttpKernel\Event\TerminateEvent))
#27 /home/**/public_html/vendor/symfony/http-kernel/HttpKernel.php(114): Symfony\Component\EventDispatcher\EventDispatcher->dispatch(Object(Symfony\Component\HttpKernel\Event\TerminateEvent), 'kernel.terminat...')
#28 /home/**/public_html/core/lib/Drupal/Core/StackMiddleware/StackedHttpKernel.php(63): Symfony\Component\HttpKernel\HttpKernel->terminate(Object(Symfony\Component\HttpFoundation\Request), Object(Drupal\Core\Render\HtmlResponse))
#29 /home/**/public_html/core/lib/Drupal/Core/DrupalKernel.php(683): Drupal\Core\StackMiddleware\StackedHttpKernel->terminate(Object(Symfony\Component\HttpFoundation\Request), Object(Drupal\Core\Render\HtmlResponse))
#30 /home/**/public_html/index.php(22): Drupal\Core\DrupalKernel->terminate(Object(Symfony\Component\HttpFoundation\Request), Object(Drupal\Core\Render\HtmlResponse))
#31 {main}

Steps to reproduce

Both local and on hosted server, getting the same issue after migrating from a Drupal 7 site that has worked without issue for years.
Run cron. Check logs

🐛 Bug report
Status

Active

Version

2.0

Component

Code

Created by

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

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

Production build 0.71.5 2024