Fatal error when enabling CKEditor 5 syles. AssertionError: assert(NestedArray::keyExists($subform, $parts)) in assert()

Created on 16 January 2025, 3 months ago

Problem/Motivation

When I enable "Styles" in a CKEditor configuration I get a fatal error:

AssertionError: assert(NestedArray::keyExists($subform, $parts)) in assert() (line 886 of core/modules/ckeditor5/src/Plugin/Editor/CKEditor5.php).
Drupal\ckeditor5\Plugin\Editor\CKEditor5::mapViolationPropertyPathsToFormNames('settings.plugins.ckeditor5_style.styles', Array) (Line: 922)
Drupal\ckeditor5\Plugin\Editor\CKEditor5::mapPairViolationPropertyPathsToFormNames('settings.plugins.ckeditor5_style.styles', Array) (Line: 707)
Drupal\ckeditor5\Plugin\Editor\CKEditor5->validateConfigurationForm(Array, Object) (Line: 207)
editor_form_filter_admin_format_validate(Array, Object)
call_user_func_array('editor_form_filter_admin_format_validate', Array) (Line: 82)
Drupal\Core\Form\FormValidator->executeValidateHandlers(Array, Object) (Line: 274)
Drupal\Core\Form\FormValidator->doValidateForm(Array, Object, 'filter_format_edit_form') (Line: 118)
Drupal\Core\Form\FormValidator->validateForm('filter_format_edit_form', Array, Object) (Line: 593)
Drupal\Core\Form\FormBuilder->processForm('filter_format_edit_form', Array, Object) (Line: 326)
Drupal\Core\Form\FormBuilder->buildForm(Object, Object) (Line: 73)
Drupal\Core\Controller\FormController->getContentResult(Object, Object) (Line: 39)
Drupal\layout_builder\Controller\LayoutBuilderHtmlEntityFormController->getContentResult(Object, Object)
call_user_func_array(Array, Array) (Line: 123)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}() (Line: 638)
Drupal\Core\Render\Renderer->executeInRenderContext(Object, Object) (Line: 121)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->wrapControllerExecutionInRenderContext(Array, Array) (Line: 97)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}() (Line: 181)
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)
require('/Users/lluisandreu/Projects/drupal/miia-drupal/web/index.php') (Line: 48)

Steps to reproduce

Use "Basic HTML" text format with CKEditor 5.
Enable "Styles" dragging the button to the toolbar
Add any style, for example a.test|Test
Crash happens and I am unable to add styles.

🐛 Bug report
Status

Active

Version

10.5

Component

ckeditor5.module

Created by

🇪🇸Spain lluisandreu

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

Comments & Activities

  • Issue created by @lluisandreu
  • First commit to issue fork.
  • 🇳🇿New Zealand quietone

    Changes are made on on 11.x (our main development branch) first, and are then back ported as needed according to the Core change policies .

    I tested on a fresh install of 11.x HEAD, using the steps in the issue summary and did not get an error.

  • Information in comment #3 suggests there are additional steps to reproduce.

  • 🇮🇳India anjaliprasannan

    I have updated the drupal version now 11.x and with this the issue does not exist.

    Steps I followed as per the description:

    • In admin/config/content/formats click on configure of Basic HTML text format
    • Add Styles plugin to the active toolbar list
    • In the CKEditor 5 plugin settings add style format like a.test|Test for example
    • Save Configuration

    The configuration gets saved.

    The fatal error that appeared before is not shown.

    Screenshot

    Moving to RTBC.

  • 🇪🇸Spain lluisandreu

    I tried the same steps in another environment and it does work as expected, this error only happens to me in local. I will update the status to "closed".
    Thanks everybody for testing.

  • 🇺🇸United States walker.45

    I'm getting the same error when enabling Styles in CKE5 and Drupal 10.4.3.

    When I drag the Style button to the active toolbar, the Manually editable HTML tags box in the Source editing settings goes red. I don't get Style settings.

    Upon saving, I get the error:

    The website encountered an unexpected error. Try again later.

    AssertionError: assert(NestedArray::keyExists($subform, $parts)) in assert() (line 886 of core/modules/ckeditor5/src/Plugin/Editor/CKEditor5.php).

    Backtrace:
    #0 /var/src/web/core/modules/ckeditor5/src/Plugin/Editor/CKEditor5.php(886): assert(false, 'assert(NestedAr...')
    #1 /var/src/web/core/modules/ckeditor5/src/Plugin/Editor/CKEditor5.php(922): Drupal\ckeditor5\Plugin\Editor\CKEditor5::mapViolationPropertyPathsToFormNames('settings.plugin...', Array)
    #2 /var/src/web/core/modules/ckeditor5/src/Plugin/Editor/CKEditor5.php(707): Drupal\ckeditor5\Plugin\Editor\CKEditor5::mapPairViolationPropertyPathsToFormNames('settings.plugin...', Array)
    #3 /var/src/web/core/modules/editor/editor.module(207): Drupal\ckeditor5\Plugin\Editor\CKEditor5->validateConfigurationForm(Array, Object(Drupal\Core\Form\SubformState))
    #4 [internal function]: editor_form_filter_admin_format_validate(Array, Object(Drupal\Core\Form\FormState))
    #5 /var/src/web/core/lib/Drupal/Core/Form/FormValidator.php(82): call_user_func_array('editor_form_fil...', Array)
    #6 /var/src/web/core/lib/Drupal/Core/Form/FormValidator.php(274): Drupal\Core\Form\FormValidator->executeValidateHandlers(Array, Object(Drupal\Core\Form\FormState))
    #7 /var/src/web/core/lib/Drupal/Core/Form/FormValidator.php(118): Drupal\Core\Form\FormValidator->doValidateForm(Array, Object(Drupal\Core\Form\FormState), 'filter_format_e...')
    #8 /var/src/web/core/lib/Drupal/Core/Form/FormBuilder.php(593): Drupal\Core\Form\FormValidator->validateForm('filter_format_e...', Array, Object(Drupal\Core\Form\FormState))
    #9 /var/src/web/core/lib/Drupal/Core/Form/FormBuilder.php(326): Drupal\Core\Form\FormBuilder->processForm('filter_format_e...', Array, Object(Drupal\Core\Form\FormState))
    #10 /var/src/web/core/lib/Drupal/Core/Controller/FormController.php(73): Drupal\Core\Form\FormBuilder->buildForm(Object(Drupal\filter\FilterFormatEditForm), Object(Drupal\Core\Form\FormState))
    #11 /var/src/web/core/modules/layout_builder/src/Controller/LayoutBuilderHtmlEntityFormController.php(39): Drupal\Core\Controller\FormController->getContentResult(Object(Symfony\Component\HttpFoundation\Request), Object(Drupal\Core\Routing\RouteMatch))
    #12 [internal function]: Drupal\layout_builder\Controller\LayoutBuilderHtmlEntityFormController->getContentResult(Object(Symfony\Component\HttpFoundation\Request), Object(Drupal\Core\Routing\RouteMatch))
    #13 /var/src/web/core/lib/Drupal/Core/EventSubscriber/EarlyRenderingControllerWrapperSubscriber.php(123): call_user_func_array(Array, Array)
    #14 /var/src/web/core/lib/Drupal/Core/Render/Renderer.php(638): Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}()
    #15 /var/src/web/core/lib/Drupal/Core/EventSubscriber/EarlyRenderingControllerWrapperSubscriber.php(124): Drupal\Core\Render\Renderer->executeInRenderContext(Object(Drupal\Core\Render\RenderContext), Object(Closure))
    #16 /var/src/web/core/lib/Drupal/Core/EventSubscriber/EarlyRenderingControllerWrapperSubscriber.php(97): Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->wrapControllerExecutionInRenderContext(Array, Array)
    #17 /var/src/vendor/symfony/http-kernel/HttpKernel.php(181): Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}()
    #18 /var/src/vendor/symfony/http-kernel/HttpKernel.php(76): Symfony\Component\HttpKernel\HttpKernel->handleRaw(Object(Symfony\Component\HttpFoundation\Request), 1)
    #19 /var/src/web/core/lib/Drupal/Core/StackMiddleware/Session.php(53): Symfony\Component\HttpKernel\HttpKernel->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
    #20 /var/src/web/core/lib/Drupal/Core/StackMiddleware/KernelPreHandle.php(48): Drupal\Core\StackMiddleware\Session->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
    #21 /var/src/web/core/lib/Drupal/Core/StackMiddleware/ContentLength.php(28): Drupal\Core\StackMiddleware\KernelPreHandle->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
    #22 /var/src/web/core/modules/big_pipe/src/StackMiddleware/ContentLength.php(32): Drupal\Core\StackMiddleware\ContentLength->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
    #23 /var/src/web/core/modules/page_cache/src/StackMiddleware/PageCache.php(116): Drupal\big_pipe\StackMiddleware\ContentLength->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
    #24 /var/src/web/core/modules/page_cache/src/StackMiddleware/PageCache.php(90): Drupal\page_cache\StackMiddleware\PageCache->pass(Object(Symfony\Component\HttpFoundation\Request), 1, true)
    #25 /var/src/web/core/lib/Drupal/Core/StackMiddleware/ReverseProxyMiddleware.php(48): Drupal\page_cache\StackMiddleware\PageCache->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
    #26 /var/src/web/core/lib/Drupal/Core/StackMiddleware/NegotiationMiddleware.php(51): Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
    #27 /var/src/web/core/lib/Drupal/Core/StackMiddleware/AjaxPageState.php(36): Drupal\Core\StackMiddleware\NegotiationMiddleware->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
    #28 /var/src/web/core/lib/Drupal/Core/StackMiddleware/StackedHttpKernel.php(51): Drupal\Core\StackMiddleware\AjaxPageState->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
    #29 /var/src/web/core/lib/Drupal/Core/DrupalKernel.php(741): Drupal\Core\StackMiddleware\StackedHttpKernel->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
    #30 /var/src/web/index.php(19): Drupal\Core\DrupalKernel->handle(Object(Symfony\Component\HttpFoundation\Request))
    #31 {main}

  • Status changed to Closed: cannot reproduce 23 days ago
  • 🇺🇸United States kenrbnsn New Jersey

    I get this error when trying to add styles. I'm on Drupal 11.1.4 (local ddev instance)

    The website encountered an unexpected error. Try again later.

    AssertionError: assert(NestedArray::keyExists($subform, $parts)) in assert() (line 857 of core/modules/ckeditor5/src/Plugin/Editor/CKEditor5.php).

    Drupal\ckeditor5\Plugin\Editor\CKEditor5::mapViolationPropertyPathsToFormNames() (Line: 893)
    Drupal\ckeditor5\Plugin\Editor\CKEditor5::mapPairViolationPropertyPathsToFormNames() (Line: 678)
    Drupal\ckeditor5\Plugin\Editor\CKEditor5->validateConfigurationForm() (Line: 59)
    editor_form_filter_admin_format_validate()
    call_user_func_array() (Line: 82)
    Drupal\Core\Form\FormValidator->executeValidateHandlers() (Line: 274)
    Drupal\Core\Form\FormValidator->doValidateForm() (Line: 118)
    Drupal\Core\Form\FormValidator->validateForm() (Line: 585)
    Drupal\Core\Form\FormBuilder->processForm() (Line: 321)
    Drupal\Core\Form\FormBuilder->buildForm() (Line: 73)
    Drupal\Core\Controller\FormController->getContentResult()
    call_user_func_array() (Line: 123)
    Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}() (Line: 593)
    Drupal\Core\Render\Renderer->executeInRenderContext() (Line: 121)
    Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->wrapControllerExecutionInRenderContext() (Line: 97)
    Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}() (Line: 183)
    Symfony\Component\HttpKernel\HttpKernel->handleRaw() (Line: 76)
    Symfony\Component\HttpKernel\HttpKernel->handle() (Line: 53)
    Drupal\Core\StackMiddleware\Session->handle() (Line: 48)
    Drupal\Core\StackMiddleware\KernelPreHandle->handle() (Line: 28)
    Drupal\Core\StackMiddleware\ContentLength->handle() (Line: 32)
    Drupal\big_pipe\StackMiddleware\ContentLength->handle() (Line: 116)
    Drupal\page_cache\StackMiddleware\PageCache->pass() (Line: 90)
    Drupal\page_cache\StackMiddleware\PageCache->handle() (Line: 48)
    Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle() (Line: 51)
    Drupal\Core\StackMiddleware\NegotiationMiddleware->handle() (Line: 36)
    Drupal\Core\StackMiddleware\AjaxPageState->handle() (Line: 51)
    Drupal\Core\StackMiddleware\StackedHttpKernel->handle() (Line: 709)
    Drupal\Core\DrupalKernel->handle() (Line: 19)

  • 🇺🇸United States kenrbnsn New Jersey

    Steps to reproduce:
    * Install a fresh copy of Drupal v11.1.4
    * Login in as admin
    * In admin/config/content/formats click on configure of Full Html
    * Drag "Styles" to active toolbar
    * Add a test style to the box
    * Click "Save"

    Error appears.

  • 🇨🇭Switzerland znerol

    This might be a race condition. I was able to reproduce the trace by dragging the style button to the toolbar, then immediately clicking on save configuration. The moment when I hit the button, the following error appeared in the browser console:

    Object { message: "\nAn AJAX HTTP request terminated abnormally.\nDebugging information follows.\nPath: /admin/config/content/formats/manage/basic_html?destination=/admin/config/content/formats%3Fcheck_logged_in%3D1&ajax_form=1\nStatusText: error\nReadyState: 0", name: "AjaxError", stack: "@http://localhost:8888/core/misc/ajax.js?v=11.1.4:196:32\n@http://localhost:8888/core/misc/ajax.js?v=11.1.4:1926:3\n" }

    My hunch is that the XHR request following the drag&drop action has been terminated before it had a chance to update the form on the server.

  • 🇨🇭Switzerland znerol

    The assertion triggers inside form validation code. If the site crashes while validating user input, then the validation process is maybe not implemented properly.

    How about converting this assertion into an if-condition?

  • I’ve identified that the AssertionError no longer occurs and saving works as expected when following these steps:

    1. Drag the Styles button to the active toolbar.
    2. Immediately afterwards, define the classes in the Styles textarea (do not leave it empty).
    3. Wait for 1 to 2 minutes.
    4. After that period, proceed to save.

    I'm using DDEV, Drupal 10.3.7.

    However, another issue remains: the Styles dropdown in CKEditor does not display any available classes (screenshot attached for reference).

  • 🇩🇪Germany m.zerres

    Solution: You have to click tab key to get the values saved. Than you can save the configuration.

Production build 0.71.5 2024