Over in #2224887: Language configuration overrides should have their own storage we're creating a LanguageConfigOverride object it is not using schema during save because the configuration object it saves are only partial. This means that we can not derive the schema if it is dynamic.

Consider the Italian override for tour.tour.tour-test

label: Tour test italian
tips:
  tour-test-1:
    label: La pioggia cade in spagna
    body: Per lo più in pianura.

the tips are plugins and without a plugin: text we can not work out the schema for the label and body fields.

Proposed resolution

To validate a LanguageConfigOverride, it must be merged with the default translation. The end result itself must pass validation for the config it tried to translate. That will work for both simple config and config entities.

ℹ️ The domain contrib module implemented a subset of this: it verifies shape conformance (strings where strings are expected, same for bools, etc), but does not execute the validation constraints.

Comments

gábor hojtsy’s picture

Issue tags: +language-config
gábor hojtsy’s picture

mgifford’s picture

That's fixed now.

Version: 8.0.x-dev » 8.1.x-dev

Drupal 8.0.6 was released on April 6 and is the final bugfix release for the Drupal 8.0.x series. Drupal 8.0.x will not receive any further development aside from security fixes. Drupal 8.1.0-rc1 is now available and sites should prepare to update to 8.1.0.

Bug reports should be targeted against the 8.1.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.2.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.1.x-dev » 8.2.x-dev

Drupal 8.1.9 was released on September 7 and is the final bugfix release for the Drupal 8.1.x series. Drupal 8.1.x will not receive any further development aside from security fixes. Drupal 8.2.0-rc1 is now available and sites should prepare to upgrade to 8.2.0.

Bug reports should be targeted against the 8.2.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.3.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.2.x-dev » 8.3.x-dev

Drupal 8.2.6 was released on February 1, 2017 and is the final full bugfix release for the Drupal 8.2.x series. Drupal 8.2.x will not receive any further development aside from critical and security fixes. Sites should prepare to update to 8.3.0 on April 5, 2017. (Drupal 8.3.0-alpha1 is available for testing.)

Bug reports should be targeted against the 8.3.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.4.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.3.x-dev » 8.4.x-dev

Drupal 8.3.6 was released on August 2, 2017 and is the final full bugfix release for the Drupal 8.3.x series. Drupal 8.3.x will not receive any further development aside from critical and security fixes. Sites should prepare to update to 8.4.0 on October 4, 2017. (Drupal 8.4.0-alpha1 is available for testing.)

Bug reports should be targeted against the 8.4.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.5.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.4.x-dev » 8.5.x-dev

Drupal 8.4.4 was released on January 3, 2018 and is the final full bugfix release for the Drupal 8.4.x series. Drupal 8.4.x will not receive any further development aside from critical and security fixes. Sites should prepare to update to 8.5.0 on March 7, 2018. (Drupal 8.5.0-alpha1 is available for testing.)

Bug reports should be targeted against the 8.5.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.6.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.5.x-dev » 8.6.x-dev

Drupal 8.5.6 was released on August 1, 2018 and is the final bugfix release for the Drupal 8.5.x series. Drupal 8.5.x will not receive any further development aside from security fixes. Sites should prepare to update to 8.6.0 on September 5, 2018. (Drupal 8.6.0-rc1 is available for testing.)

Bug reports should be targeted against the 8.6.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.7.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.6.x-dev » 8.8.x-dev

Drupal 8.6.x will not receive any further development aside from security fixes. Bug reports should be targeted against the 8.8.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.9.x-dev branch. For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

Version: 8.8.x-dev » 8.9.x-dev

Drupal 8.8.7 was released on June 3, 2020 and is the final full bugfix release for the Drupal 8.8.x series. Drupal 8.8.x will not receive any further development aside from security fixes. Sites should prepare to update to Drupal 8.9.0 or Drupal 9.0.0 for ongoing support.

Bug reports should be targeted against the 8.9.x-dev branch from now on, and new development or disruptive changes should be targeted against the 9.1.x-dev branch. For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

Version: 8.9.x-dev » 9.2.x-dev

Drupal 8 is end-of-life as of November 17, 2021. There will not be further changes made to Drupal 8. Bugfixes are now made to the 9.3.x and higher branches only. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 9.2.x-dev » 9.3.x-dev

Version: 9.3.x-dev » 9.4.x-dev

Drupal 9.3.15 was released on June 1st, 2022 and is the final full bugfix release for the Drupal 9.3.x series. Drupal 9.3.x will not receive any further development aside from security fixes. Drupal 9 bug reports should be targeted for the 9.4.x-dev branch from now on, and new development or disruptive changes should be targeted for the 9.5.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 9.4.x-dev » 9.5.x-dev

Drupal 9.4.9 was released on December 7, 2022 and is the final full bugfix release for the Drupal 9.4.x series. Drupal 9.4.x will not receive any further development aside from security fixes. Drupal 9 bug reports should be targeted for the 9.5.x-dev branch from now on, and new development or disruptive changes should be targeted for the 10.1.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 9.5.x-dev » 11.x-dev

Drupal core is moving towards using a “main” branch. As an interim step, a new 11.x branch has been opened, as Drupal.org infrastructure cannot currently fully support a branch named main. New developments and disruptive changes should now be targeted for the 11.x branch. For more information, see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

smustgrave’s picture

Status: Active » Postponed (maintainer needs more info)
Issue tags: +stale-issue-cleanup

Thank you for creating this issue to improve Drupal.

We are working to decide if this task is still relevant to a currently supported version of Drupal. There hasn't been any discussion here for over 8 years which suggests that this has either been implemented or is no longer relevant. Your thoughts on this will allow a decision to be made.

Since we need more information to move forward with this issue, the status is now Postponed (maintainer needs more info). If we don't receive additional information to help with the issue, it may be closed after three months.

Thanks!

borisson_’s picture

While I think it has a low priority, I think it still makes sense to validate that the schema of translated items matches the original type.
I think this issue should stay open.

smustgrave’s picture

Status: Postponed (maintainer needs more info) » Active
borisson_’s picture

Issue tags: +validation

Adding validation tag

mably’s picture

We have the same problem when saving Domain overrides.

What is the best way to handle it?

Version: 11.x-dev » main

Drupal core is now using the main branch as the primary development branch. New developments and disruptive changes should now be targeted to the main branch.

Read more in the announcement.

wim leers’s picture

Category: Task » Bug report
Priority: Normal » Major
Issue tags: +Experience Builder, +data integrity
Related issues: +#3583854: [upstream] Validate LanguageConfigOverrides targeting Canvas config entities

I was kinda shocked to learn this is not at all validated today. I found this issue thanks to AI, after I described the current status for config translations in core and what the data integrity consequences are for Canvas: #3583854: [upstream] Validate LanguageConfigOverrides targeting Canvas config entities.

wim leers’s picture

Issue summary: View changes
Issue tags: -stale-issue-cleanup

@borisson_++ for #18

Added proposed resolution.

wim leers’s picture

I bet that a LanguageConfigOverride for node.type.article that looks like this:

langcode: none
status: of
dependencies: this
name: is
type: validated
description: in
help: any
new_revision: way
preview_mode: at
display_submitted: all 

would yield interesting results.

  1. load time: it'd happily be loaded
  2. save time: ConfigFactoryOverrideBase::filterOverride() won't filter any of those away — because the keys all exist
wim leers’s picture

Issue summary: View changes

I see the Domain module implemented a subset of what is needed, nice!

borisson_’s picture

Issue tags: +drupalcampFR2026

It looks like the domain module is only doing this on save, is that were we want to change this as well or do we want to do it while loading the config?

#25 sounds like a fun way to break a website :D. To prevent this, I think we need to ensure that we validate after loading as well. I'm wondering if that makes performance much slower though.

wim leers’s picture

Validate-upon-load doesn't seem feasible. We don't do that for content entities either. Validate-on-save would already be a major improvement 😅

borisson_’s picture

Validate-on-save would already be a major improvement 😅

I've spent the last days wondering about this, because I wasn't sure if I agree. You are correct for language overrides, and config overrides that come from config split, don't even use the same mechanism.
I was wondering if this would introduce a difference between how overrides that are coming from settings.php work compared to other overrides, but thinking about it some more - those can stay with their own way of working - they are already very different.

So yes, I agree that validate-on-save is good here.

wim leers’s picture

Status: Active » Needs review

Canvas added support for this yesterday in https://git.drupalcode.org/project/canvas/-/commit/40e36b738bda6d61f89b2...

  1. validation constraint: https://git.drupalcode.org/project/canvas/-/blob/897424363cc2cc1421d313d...
  2. a \Drupal\Core\Config\Development\ConfigSchemaChecker sibling: https://git.drupalcode.org/project/canvas/-/blob/897424363cc2cc1421d313d...

AFAICT both would be pretty easy to add to core (the second one could be merged into the existing \Drupal\Core\Config\Development\ConfigSchemaChecker). Thoughts? :)

borisson_’s picture

Both the constract and the ConfigSchemaChecker equivalent look to be easy enough to read. I don't like that there's basically an array of things that we need to keep track of where the constraint is automatically added.
As soon as one part of the schema has a translatable property, should be added automatically?
This is now limited to Config entities, but there are other types that can also have language overrides?

smustgrave’s picture

Status: Needs review » Needs work

Don't see an MR to review, but if it were in review to add to core I think there is enough support here to do that. :)

wim leers’s picture

Status: Needs work » Active

#32: yep, sorry — wanted to get a general +1 for approach.

This is now limited to Config entities, but there are other types that can also have language overrides?

Yes and no — the current names in Canvas do imply that, but there's nothing entity-specific about the code: it relies solely on plain config + schema:

      // Simulate what Config::setOverriddenData() does: merge override onto
      // base to get the full picture that will be served to consumers.
      // @see \Drupal\Core\Config\Config::setOverriddenData()
      $merged = NestedArray::mergeDeepArray([$base_data, $override_data], TRUE);
      $typed = $this->typedConfigManager->createFromNameAndData($name, $merged);
      $violations = $typed->validate();
I don't like that there's basically an array of things that we need to keep track of where the constraint is automatically added.
As soon as one part of the schema has a translatable property, should be added automatically?

This I did not follow 😅🙈 Could you rephrase?

borisson_’s picture

I tried to build enough context again to understand what I wanted to say here, I don't remember.
In any case, I am +1 on this issue and I really think this a good idea to introduce load-on-save for language overrides.