Call to admin/config/system/csp results in TypeError

Created on 28 March 2025, 15 days ago

Problem/Motivation

Unable to access the configuration form

Steps to reproduce

Go to admin/config/system/csp results in The website encountered an unexpected error. Try again later.
dblog message:
TypeError: Drupal\Component\Utility\Html::escape(): Argument #1 ($text) must be of type string, null given, called in /var/www/web132/drupal/web/core/lib/Drupal/Component/Render/FormattableMarkup.php on line 238 in Drupal\Component\Utility\Html::escape() (line 431 of /var/www/web132/drupal/web/core/lib/Drupal/Component/Utility/Html.php).
Backtrace:
#0 /var/www/web132/drupal/web/core/lib/Drupal/Component/Render/FormattableMarkup.php(238): Drupal\Component\Utility\Html::escape()
#1 /var/www/web132/drupal/web/core/lib/Drupal/Component/Render/FormattableMarkup.php(211): Drupal\Component\Render\FormattableMarkup::placeholderEscape()
#2 /var/www/web132/drupal/web/core/lib/Drupal/Core/StringTranslation/TranslatableMarkup.php(195): Drupal\Component\Render\FormattableMarkup::placeholderFormat()
#3 /var/www/web132/drupal/web/core/lib/Drupal/Component/Utility/ToStringTrait.php(15): Drupal\Core\StringTranslation\TranslatableMarkup->render()
#4 /var/www/web132/drupal/web/core/lib/Drupal/Core/Messenger/Messenger.php(54): Drupal\Core\StringTranslation\TranslatableMarkup->__toString()
#5 /var/www/web132/drupal/web/core/lib/Drupal/Core/Messenger/Messenger.php(46): Drupal\Core\Messenger\Messenger->addMessage()
#6 /var/www/web132/drupal/web/modules/contrib/csp/src/Form/CspSettingsForm.php(487): Drupal\Core\Messenger\Messenger->addError()
#7 [internal function]: Drupal\csp\Form\CspSettingsForm->buildForm()
#8 /var/www/web132/drupal/web/core/lib/Drupal/Core/Form/FormBuilder.php(528): call_user_func_array()
#9 /var/www/web132/drupal/web/core/lib/Drupal/Core/Form/FormBuilder.php(279): Drupal\Core\Form\FormBuilder->retrieveForm()
#10 /var/www/web132/drupal/web/core/lib/Drupal/Core/Controller/FormController.php(73): Drupal\Core\Form\FormBuilder->buildForm()
#11 [internal function]: Drupal\Core\Controller\FormController->getContentResult()
#12 /var/www/web132/drupal/web/core/lib/Drupal/Core/EventSubscriber/EarlyRenderingControllerWrapperSubscriber.php(123): call_user_func_array()
#13 /var/www/web132/drupal/web/core/lib/Drupal/Core/Render/Renderer.php(593): Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}()
#14 /var/www/web132/drupal/web/core/lib/Drupal/Core/EventSubscriber/EarlyRenderingControllerWrapperSubscriber.php(121): Drupal\Core\Render\Renderer->executeInRenderContext()
#15 /var/www/web132/drupal/web/core/lib/Drupal/Core/EventSubscriber/EarlyRenderingControllerWrapperSubscriber.php(97): Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->wrapControllerExecutionInRenderContext()
#16 /var/www/web132/drupal/vendor/symfony/http-kernel/HttpKernel.php(183): Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}()
#17 /var/www/web132/drupal/vendor/symfony/http-kernel/HttpKernel.php(76): Symfony\Component\HttpKernel\HttpKernel->handleRaw()
#18 /var/www/web132/drupal/web/core/lib/Drupal/Core/StackMiddleware/Session.php(53): Symfony\Component\HttpKernel\HttpKernel->handle()
#19 /var/www/web132/drupal/web/core/lib/Drupal/Core/StackMiddleware/KernelPreHandle.php(48): Drupal\Core\StackMiddleware\Session->handle()
#20 /var/www/web132/drupal/web/core/lib/Drupal/Core/StackMiddleware/ContentLength.php(28): Drupal\Core\StackMiddleware\KernelPreHandle->handle()
#21 /var/www/web132/drupal/web/core/modules/big_pipe/src/StackMiddleware/ContentLength.php(32): Drupal\Core\StackMiddleware\ContentLength->handle()
#22 /var/www/web132/drupal/web/core/modules/page_cache/src/StackMiddleware/PageCache.php(116): Drupal\big_pipe\StackMiddleware\ContentLength->handle()
#23 /var/www/web132/drupal/web/core/modules/page_cache/src/StackMiddleware/PageCache.php(90): Drupal\page_cache\StackMiddleware\PageCache->pass()
#24 /var/www/web132/drupal/web/core/modules/ban/src/BanMiddleware.php(50): Drupal\page_cache\StackMiddleware\PageCache->handle()
#25 /var/www/web132/drupal/web/core/lib/Drupal/Core/StackMiddleware/ReverseProxyMiddleware.php(48): Drupal\ban\BanMiddleware->handle()
#26 /var/www/web132/drupal/web/core/lib/Drupal/Core/StackMiddleware/NegotiationMiddleware.php(51): Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle()
#27 /var/www/web132/drupal/web/core/lib/Drupal/Core/StackMiddleware/AjaxPageState.php(36): Drupal\Core\StackMiddleware\NegotiationMiddleware->handle()
#28 /var/www/web132/drupal/web/core/lib/Drupal/Core/StackMiddleware/StackedHttpKernel.php(51): Drupal\Core\StackMiddleware\AjaxPageState->handle()
#29 /var/www/web132/drupal/web/core/lib/Drupal/Core/DrupalKernel.php(709): Drupal\Core\StackMiddleware\StackedHttpKernel->handle()
#30 /var/www/web132/drupal/web/index.php(19): Drupal\Core\DrupalKernel->handle()
#31 {main}

Proposed resolution

Remaining tasks

User interface changes

API changes

Data model changes

🐛 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

  • Issue created by @johnwt
  • 🇮🇳India Raveen Kumar

    I have installed the module using composer require 'drupal/csp:^2.2'
    I am using drupal latest version i.e, Drupal : 11.1.5

    On visit of - admin/config/system/csp , I was able to access config form. As you can see my attached screenshot.

    Could you please confirm if issue still persists here.

    And Thank You!!

  • I have the same, i.e. Drupal : 11.1.5 and csp installed with composer require 'drupal/csp:^2.2', and the error persists.

  • 🇨🇦Canada gapple

    The form is trying to indicate that there is an issue with your policy's reporting configuration
    https://git.drupalcode.org/project/csp/-/blob/2.x/src/Form/CspSettingsFo...

    What are the values in your configuration for csp.settings:enforce.reporting and csp.settings:report-only.reporting?

  • I am facing the same issue.
    I am on Drupal: 11.1.6, CSP: 2.2.2

    The screenshot attached shows my configuration object.

    Under which object would I find the following settings
    csp.settings:enforce.reporting
    csp.settings:report-only.reporting

    Please let me know, if you need more information.
    Thanks

  • I am facing the same issue
    I am on drupal.core: 11.1.6, drupal/csp: 2.2.2

    The screenshot below shows my configuration object.

    Where would I find the said properties?
    csp.settings:enforce.reporting
    csp.settings:report-only.reporting

Production build 0.71.5 2024