InvalidArgumentException: The configuration property default_value.0.settings.context_mapping.node doesn't exist.

Created on 19 August 2024, 8 months ago

Problem/Motivation

I have created a block through code, and I have defined the context in the block's description.

In the block's build function, I retrieve the context to use it.

When I configure the default value of the field and specify the block I am going to use, along with the "node from URL" context option,

Upon saving the field, I get the following error:

InvalidArgumentException: The configuration property default_value.0.settings.context_mapping.node doesn't exist. in Drupal\Core\Config\Schema\ArrayElement->get() (line 76 of core/lib/Drupal/Core/Config/Schema/ArrayElement.php).

Drupal\Core\Config\StorableConfigBase->castValue() (Line: 218)
Drupal\Core\Config\StorableConfigBase->castValue() (Line: 218)
Drupal\Core\Config\StorableConfigBase->castValue() (Line: 218)
Drupal\Core\Config\StorableConfigBase->castValue() (Line: 218)
Drupal\Core\Config\StorableConfigBase->castValue() (Line: 218)
Drupal\Core\Config\StorableConfigBase->castValue() (Line: 211)
Drupal\Core\Config\Config->save() (Line: 274)
Drupal\Core\Config\Entity\ConfigEntityStorage->doSave() (Line: 520)
Drupal\Core\Entity\EntityStorageBase->save() (Line: 253)
Drupal\Core\Config\Entity\ConfigEntityStorage->save() (Line: 339)
Drupal\Core\Entity\EntityBase->save() (Line: 608)
Drupal\Core\Config\Entity\ConfigEntityBase->save() (Line: 205)
Drupal\field_ui\Form\FieldConfigEditForm->save()
call_user_func_array() (Line: 114)
Drupal\Core\Form\FormSubmitter->executeSubmitHandlers() (Line: 52)
Drupal\Core\Form\FormSubmitter->doSubmitForm() (Line: 597)
Drupal\Core\Form\FormBuilder->processForm() (Line: 325)
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: 580)
Drupal\Core\Render\Renderer->executeInRenderContext() (Line: 124)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->wrapControllerExecutionInRenderContext() (Line: 97)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}() (Line: 169)
Symfony\Component\HttpKernel\HttpKernel->handleRaw() (Line: 81)
Symfony\Component\HttpKernel\HttpKernel->handle() (Line: 58)
Drupal\Core\StackMiddleware\Session->handle() (Line: 48)
Drupal\Core\StackMiddleware\KernelPreHandle->handle() (Line: 106)
Drupal\page_cache\StackMiddleware\PageCache->pass() (Line: 85)
Drupal\page_cache\StackMiddleware\PageCache->handle() (Line: 48)
Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle() (Line: 51)
Drupal\Core\StackMiddleware\NegotiationMiddleware->handle() (Line: 23)
Stack\StackedHttpKernel->handle() (Line: 718)
Drupal\Core\DrupalKernel->handle() (Line: 19)


I have try also the patchs from https://www.drupal.org/project/block_field/issues/2861670 🐛 Config schema is wrong and changing the available blocks for a "Block (plugin)" field produces a Recoverable fatal error RTBC but doesn't works, I'm with drupa 9.5.11 and the block field version 8.x-1.0-rc5

Steps to reproduce

  1. Create a custom block programatically
  2. Set the context_definitions in the block class description
  3. Create a block field
  4. Select the block create programatically, only that block
  5. In the default value options set the block and also set the node from url and save the field.
  6. If it's not set the "node from url" also gives the error.
🐛 Bug report
Status

Active

Component

Code

Created by

🇪🇸Spain oskar_calvo

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

Comments & Activities

Production build 0.71.5 2024