Problem/Motivation

When I try to arrange text formats and editors settings I get the following error.

Symfony\Component\Validator\Exception\LogicException: The LangcodeRequiredIfTranslatableValues constraint can only operate on the root object being validated. in Drupal\Core\Config\Plugin\Validation\Constraint\LangcodeRequiredIfTranslatableValuesConstraintValidator->validate() (line 26 of var/www/html/mysite/web/core/lib/Drupal/Core/Config/Plugin/Validation/Constraint/LangcodeRequiredIfTranslatableValuesConstraintValidator.php).

This was caused by #3427564: Require `langcode: …` only for simple config that contains translatable values.

Steps to reproduce

On Drupal 10.3, edit and then save a text format that uses CKEditor.

Proposed resolution

Convert the LogicException to a E_USER_DEPRECATED error. This is a quick fix for sites broken by Drupal 10.3. Another fix for 11.x can be done in a follow-up.

Remaining tasks

Implement.

User interface changes

None.

API changes

None.

Data model changes

None.

Release notes snippet

Text formats could not be saved due to config translation validation new in Drupal 10.3. The LogicException has been replaced with a E_USER_DEPRECATED error.

Issue fork drupal-3449851

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

Anonymous’s picture

jaydenpearly created an issue. See original summary.

kopeboy’s picture

Title: Validation constraints error » Validation constraints error
Category: Support request » Bug report

I can confirm I'm having this error twice now (on two different sites), and it doesn't allow me to change any text format configuration that has CKEditor5 anymore.

Drupal 10.2.6 doesn't have this. This doesn't come out of the box but after playing around with CKEditor toolbar or removing a text format.


error trace

Drupal\Core\TypedData\Validation\RecursiveContextualValidator->validateConstraints() (Line: 154)
Drupal\Core\TypedData\Validation\RecursiveContextualValidator->validateNode() (Line: 164)
Drupal\Core\TypedData\Validation\RecursiveContextualValidator->validateNode() (Line: 164)
Drupal\Core\TypedData\Validation\RecursiveContextualValidator->validateNode() (Line: 164)
Drupal\Core\TypedData\Validation\RecursiveContextualValidator->validateNode() (Line: 106)
Drupal\Core\TypedData\Validation\RecursiveContextualValidator->validate() (Line: 93)
Drupal\Core\TypedData\Validation\RecursiveValidator->validate() (Line: 132)
Drupal\Core\TypedData\TypedData->validate() (Line: 234)
Drupal\ckeditor5\Plugin\Editor\CKEditor5::validatePair() (Line: 680)
Drupal\ckeditor5\Plugin\Editor\CKEditor5->validateConfigurationForm() (Line: 207)
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: 593)
Drupal\Core\Form\FormBuilder->processForm() (Line: 326)
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: 638)
Drupal\Core\Render\Renderer->executeInRenderContext() (Line: 121)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->wrapControllerExecutionInRenderContext() (Line: 97)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}() (Line: 181)
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: 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: 36)
Drupal\Core\StackMiddleware\AjaxPageState->handle() (Line: 51)
Drupal\Core\StackMiddleware\StackedHttpKernel->handle() (Line: 737)
Drupal\Core\DrupalKernel->handle() (Line: 19)

pingwin_cracow’s picture

Confirmed, I have the same problem after updating to Drupal 10.3.0-beta1
Exactly the same errors mentioned above.

cilefen’s picture

Priority: Normal » Major
pingwin_cracow’s picture

I updated to Drupal 10.3.0 and the problem still persists which is very irritating.
Is there a chance for a quick solution so that I can edit the text format settings?

cilefen’s picture

Yes. Performing a git bisect on a checkout of Drupal Core between a good and bad release tag will quickly find the issue that introduced the regression.

Pablo_Pukha made their first commit to this issue’s fork.

cilefen’s picture

Title: Validation constraints error » Symfony\Component\Validator\Exception\LogicException: The LangcodeRequiredIfTranslatableValues constraint can only operate on the root object being validated
liam morland’s picture

liam morland’s picture

This merge request changes the LogicException to a E_USER_DEPRECATED error. This allows text formats to be saved. This may be a good short-term fix.

liam morland’s picture

liam morland’s picture

This patch represents the current state of the merge request.

rei’s picture

in my case I was getting the same error message after adding ckeditor5_template button on the toolbar.
After applied the patch in #13, the editor doesn't show up/blank at node edit page.
this error did't occur with drupal 10.2.7

pingwin_cracow’s picture

Drupal 10.3.0
php 8.4
admin theme: Gin
fix #13 worked fine after clearing cache, Ckeditor 5 bar is correct for all options (Full, Office, etc.)

I hope the patch will be included in the next Drupal 10.3 patch

Thank you very much for help.

vincent.hoehn’s picture

I can confirm that the patch in #13 fixes the issue. I hope it will be included in core soon!

smustgrave’s picture

Version: 10.3.x-dev » 11.x-dev
Status: Needs review » Needs work
Issue tags: +Needs issue summary update

Change should be turned to an MR.

Issue summary is incomplete so that should be updated using the standard template.

Have not reviewed patch

liam morland’s picture

Version: 11.x-dev » 10.3.x-dev
Issue summary: View changes
Status: Needs work » Needs review
Issue tags: -Needs issue summary update

The change already is a MR; see #10. #13 is there to allow patching from Composer.

This was intentionally targeting Drupal 10.3 because this is a quick solution to fix broken sites and people will probably want some other fix in 11.x.

Issue summary updated.

smustgrave’s picture

it's missed the 10.3 boat unfortunately

liam morland’s picture

I was anticipating this would deploy with 10.3.1 to fix sites broken by 10.3.0.

smustgrave’s picture

Status: Needs review » Needs work

Looking at the steps

On Drupal 10.3, edit and then save a text format

this doesn't cause any issue, would imagine a test failure would of happened if so. So there needs to be determined what the issue is and have coverage for that.

But this missed 10.3 and can't be removed in 11 as that's out now too. So if anything it would be 10.4 and removed in 12 if it gets added.

MR should be made for 11.x (main branch)

liam morland’s picture

Issue summary: View changes

Did you look at the patch? I expect that if this patch were proposed to be merged into Drupal 11 or 12, that would be refused on the basis that the LogicException is correct and that the bug is buried elsewhere in the code. That is probably true. What we need now is a fix for the sites that were broken by the 10.3.0 upgrade.

The issue only appears when saving a text format that uses CKEditor. It is possible that there is some other condition also required to trigger the problem. Several people are having this problem and the fix works for them.

smustgrave’s picture

Status: Needs work » Needs review

Okay I'm going to leave this issue, I don't believe its going to be merged but will leave in review for others

liam morland’s picture

Status: Needs review » Needs work

Do you have another suggestion for how to fix this?

If this cannot be quickly fixed, there should be a warning message to caution people against upgrading to Drupal 10.3.

smustgrave’s picture

I mean the exception is very vague, I imagine the scenario is that some config got in after #3427564: Require `langcode: …` only for simple config that contains translatable values so would be more useful to say what config is causing the issue. Then you could go and fix the file.

But that's an untested theory

liam morland’s picture

Status: Needs work » Needs review

I didn't mean to switch the status.

smustgrave’s picture

Opened this yesterday too as I saw it with configuration inspector.

liam morland’s picture

We are not using config_inspector and yet we see this error. So, my hunch is that the other issue should be closed as a duplicate of this. Perhaps the error message should point out what config is wrong, as you suggest in the other issue.

shani maurya’s picture

I can confirm that the patch in #13 fixes the issue for drupal core 10.3

solideogloria’s picture

Status: Needs review » Reviewed & tested by the community

Patch #13 works in Drupal 10.3. (I don't use config_inspector either.)

dadderley’s picture

Same problem with 10.3.0
Cannot modify existing text format

solideogloria’s picture

@dadderley If you still have a problem in 10.3, then your text format is using an invalid CKEditor plugin, or maybe something else is wrong in the text format's configuration. I had the same problem, too, prior to discovering that.

You need to discover why an error is being thrown. Even if the Exception is not thrown after applying the patch, there is still an error being triggered, and it will again throw an Exception in Drupal 11.

quietone’s picture

Issue tags: +Needs title update

The title becomes the commit message and an error message is not very useful when going through the logs. Can someone change this to what is being fixed?

solideogloria’s picture

Title: Symfony\Component\Validator\Exception\LogicException: The LangcodeRequiredIfTranslatableValues constraint can only operate on the root object being validated » Replace LogicException with trigger_error in LangcodeRequiredIfTranslatableValues constraint

How's this?

solideogloria’s picture

Issue tags: -Needs title update
dadderley’s picture

@solideogloria
I have a few sites that have been updated to D 10.3.0

This is happening in sites that use this plugin
Obfuscate Email
https://www.drupal.org/project/obfuscate_email

This is a new issue with the plugin that is related to the D 10.3.0 upgrade
https://www.drupal.org/project/obfuscate_email/issues/3457393

I cannot uninstall the plugin because a text format requires it.
I cannot disable the plugin because it throws this error when trying to save the text format.

Error message
'click' is not a supported key.
'click_label' is not a supported key.

Interestingly enough on one of the updated sites where I have the Obfuscate Email plugin installed, I don't get the error message, just a WSOD when I try to save the text format.

Is this helpful information?

Edit
There has been a new release of the Obfuscate Email module which seems to have cleared up the issue that I mentioned.

solideogloria’s picture

If you still have the issue, try setting a breakpoint in the code where the error is thrown from. You might have another plugin throwing errors.

You could also try disabling all non-core modules and see if that fixes it, and try to figure out if it's related to a certain module.

dadderley’s picture

@solideogloria
I found the offending Ckeditor plugin.
Thanks again.

See this issue

Symfony\Component\Validator\Exception\LogicException: The LangcodeRequiredIfTranslatableValues constraint can only operate on the root object being validated.
https://www.drupal.org/project/ckeditor_indentblock/issues/3457094

alexpott’s picture

This error indicates that type: config_object has been added in an incorrect place in the schema. I agree that the friendly thing to do here is to emit a deprecation in 10.x and leave a break in 11.x as this is not a great thing. The config that has config_object placed at the wrong level will be invalid according to its schema.

alexpott’s picture

Status: Reviewed & tested by the community » Needs work

I've added some comments to address to the MR.

catch’s picture

Not sure what's best to do about the change record here, should we add a new CR alongside the ones that were already added for #3427629: `langcode: …` is now required for config objects that contain translatable values?

I think deprecation in 10.3 to exception in 11.x is OK given the config schema was invalid in these modules already.

catch’s picture

Made an attempt at a CR https://www.drupal.org/node/3459863

alexpott’s picture

Status: Needs work » Needs review

I've fixed the 10.3.x MR and I've provided an 11.x that improves the exception message so it is less cryptic. The deprecation message for 10.x is also explicit now too.

smustgrave changed the visibility of the branch 11.x to hidden.

smustgrave changed the visibility of the branch 10.3.x to hidden.

smustgrave’s picture

Status: Needs review » Reviewed & tested by the community
Issue tags: +Needs Review Queue Initiative

Had to run the tests locally since can't run the test-only feature here

Failed asserting that exception message 'The LangcodeRequiredIfTranslatableValues constraint can only operate on the root object being validated.' contains 'The LangcodeRequiredIfTranslatableValues constraint is applied to 'config_test.foo::broken_langcode_required'. This constraint can only operate on the root object being validated.'.

Love the updated text, super helpful

  • catch committed f932d803 on 10.3.x
    Issue #3449851 by Liam Morland, alexpott, smustgrave, solideogloria,...

  • catch committed a17e648a on 10.4.x
    Issue #3449851 by Liam Morland, alexpott, smustgrave, solideogloria,...

  • catch committed f1263c54 on 11.0.x
    Issue #3449851 by Liam Morland, alexpott, smustgrave, solideogloria,...

  • catch committed b12dd10f on 11.x
    Issue #3449851 by Liam Morland, alexpott, smustgrave, solideogloria,...
catch’s picture

Status: Reviewed & tested by the community » Fixed

Committed/pushed to 11.x, 11.0.x, 10.4.x and 10.3.x respectively, thanks!

xjm’s picture

Issue tags: +10.3.3 release notes
xjm’s picture

Issue tags: -10.3.3 release notes +10.3.2 release notes

I seem to have invented a patch release in my head.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.