A profile without a version causes a fatal error on status report page

Created on 9 March 2025, 3 days ago

Problem/Motivation

As reported in 'Add Exception for TypeError Argument must be String in \Drupal\Component\Utility\Html escape{}' Add Exception for TypeError Argument must be String in \Drupal\Component\Utility\Html escape{} Needs work the error message on /admin/reports/status (or in the logs for a white screen of death):

"Drupal\Component\Utility\Html::escape(): Argument #1 () must be of type string, null given, called in /var/www/html/web/core/lib/Drupal/Component/Render/FormattableMarkup.php on line 238"

And then leads the perplexed site maintainer or developer on a journey through TranslatableMarkup and Twig\Template->display() and twig_template_render and Drupal\Core\Render\Renderer->doRender among other less notable stops, with the template and rendering stuff all showing up twice. But not once does the stacktrace give a hint of what code actually started the problem.

Using a debugger one can go a few steps down (up?) the stack to Drupal\Core\StringTranslation\TranslatableMarkup and find the variables passed into it. These made clear that the underlying problem is that a custom profile has no version string.

Steps to reproduce

Create a custom profile `profiles/example/example.info.yml` with:

```yml
name: 'Example profile'
type: profile
core_version_requirement: ^11
```

Adding any version string, even version: VERSION resolves this error.

Proposed resolution

Add Exception for TypeError Argument must be String in \Drupal\Component\Utility\Html escape{} Needs work should be resolved to make this no longer a fatal error. In this case though, a preprocessor or something should replace NULL with "No version specified".

Alternatively, the lack of a version string in the custom profile could trigger an error message to that effect before it can be installed.

Remaining tasks

User interface changes

Introduced terminology

API changes

Data model changes

Release notes snippet

🐛 Bug report
Status

Active

Version

11.1 🔥

Component

base system

Created by

🇺🇸United States mlncn Minneapolis, MN, USA

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

Comments & Activities

Production build 0.71.5 2024