Closed (fixed)
Project:
Drupal core
Version:
11.x-dev
Component:
filter.module
Priority:
Normal
Category:
Task
Assigned:
Unassigned
Reporter:
Created:
20 Oct 2023 at 10:46 UTC
Updated:
6 Mar 2024 at 09:44 UTC
Jump to comment: Most recent
Filter module settings has 1 property paths that are not yet validatable:
./vendor/bin/drush config:inspect --filter-keys=filter.settings --detail --list-constraints --fields=key,validatability,constraints
➜ 🤖 Analyzing…
---------------------------------------------- ------------- ------------------------------------------
Key Validatable Validation constraints
---------------------------------------------- ------------- ------------------------------------------
filter.settings 80% ValidKeys: '<infer>'
RequiredKeys: '<infer>'
filter.settings: Validatable ValidKeys: '<infer>'
RequiredKeys: '<infer>'
filter.settings:_core Validatable ValidKeys:
- default_config_hash
RequiredKeys: '<infer>'
filter.settings:_core.default_config_hash Validatable NotNull: { }
Regex: '/^[a-zA-Z0-9\-_]+$/'
Length: 43
↣ PrimitiveType: { }
filter.settings:always_show_fallback_choice Validatable ↣ PrimitiveType: { }
filter.settings:fallback_format NOT ⚠️ @todo Add validation constraints here
---------------------------------------------- ------------- ------------------------------------------
11.x.composer require drupal/config_inspector — or manually install https://www.drupal.org/project/config_inspector/releases/2.1.5 or newer (which supports Drupal 11!)composer require drush/drushvendor/bin/drush config:inspect --filter-keys=filter.settings --detail --list-constraintsAdd validation constraints to:
filter.settings:fallback_formatThis requires looking at the existing code and admin UI (if any) to understand which values could be considered valid. Eventually this needs to be reviewed by the relevant subsystem maintainer.
For examples, search *.schema.yml files for the string constraints: 😊
Reach out to @borisson_ or @wimleers in the #distributions-and-recipes.
filter.settings:fallback_formatNone.
None.
More validation 🚀
None.
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
Comment #2
borisson_Comment #3
borisson_Comment #6
eli-tComment #8
eli-tThis MR introduces a new Constraint that checks that an entity with a given ID and entity type exists. This is probably useful in a number of other places so it would be worth reviewing issues that might need it and linking so we're not duplicating work
Comment #9
eli-tThe assertion that is currently failing is in ConfigImportAllTest::testInstallUninstall() on line 147
Comment #10
eli-tThe test is asserting that a set of modules are enabled, and is failing because block_content is not enabled. However, debugging shows it would fail on other modules - here's a list of the enabled status of all checked modules.
Comment #11
borisson_I have tried to figure out what the problem is what that
testInstallUninstall, I don't understand what the problem is, there is no config errors when installing or when uninstalling, so why some modules don't want to be installed is a mystery to me.I don't think it is because those modules all depend on filter, because for example workspaces only depends on user.
Comment #12
nireneko commentedI checked this, and I can't find the problem, but like @borisson_ sais, must be in the config, debugging the core.extensions.yml file has the full list of modules that must be installed, but when the syncronization is executed in the test
ConfigImportAllTestlines:Is not installing all the modules.
I tried to debug the syncronization import in
Drupal\config\Form\ConfigSync, but I can't :(Getting the list of enabled modules before
line, there are 26 installed modules of 74.
Also something strange, in the new validator
EntityExistsConstraintValidator, adding one "return;" before add the violation (or removing the violation), the test is green and I don't understand why, because in my case, that point never is reached, the 'if' always is 'true'.Comment #13
marvil07 commentedI could not find the actual problem either.
Said that, hopefully some extra clues follow.
@nireneko, that is expected, a return or the non-creation of a violation means the constraint passes validation.
As stated at previous comments, there are multiple modules not enabled on the configuration import done on the failing test.
Finding the error is a bit tricky, since
ConfigImportAllTest::testInstallUninstall()is using the configuration synchronization UI, and that uses the batch API.Inside the Batch API, errors seem to not be relied, or at least not in tests, see
ob_\*calls at https://git.drupalcode.org/project/drupal/-/blob/0bbf07394de4a370c28b904....Trying to figure the problem out, I noticed that if the module installer service is used to enable the modules, they can be enabled.
E.g. adding the following change will make block_content module enabled correctly, and the error will be reported on the next not re-enabled module, book.
In other words, the code path enabling the modules with the configuration synchronization form on the test is doing something different than the call to
\Drupal::service('module_installer')->install().What exactly, not quite sure.
Overall, it may be that the new configuration validation is correctly triggering a problem, but that problem seems to only exist on the testing code path, and not on the normal code path, outside test via phpunit.
Comment #14
claudiu.cristeaI find something weird with schema of filters.
This is text format schema (removed some parts for readability):
Each filter is of type
filter:Each filter's settings is of type
filter_settings.<filter_plugin_id>, defaulting tofilter_settings.*But here comes the weirdness: Each
filter_settings.<filter_plugin_id>is again of typefilter(except filter_settings.* which correctly goes to a sequence)For instance:
I think each
filter_settings.<filter_plugin_id>should be of type mappingAm I missing something?
Comment #15
claudiu.cristeaI've opened #3404431: Filter settings schema types are incorrect for #14
Comment #16
wim leers#14: you re-discovered #3401837: Add basic validation to config schema definitions 😄
EDIT: reviewed your new issue 😊
Comment #17
wim leersBlocked on #3404431: Filter settings schema types are incorrect.
Comment #18
wim leers#3404431: Filter settings schema types are incorrect landed!
Comment #19
wim leersComment #20
wim leersLifted some code from #3412361: Mark Editor config schema as fully validatable to expand what the existing
ConfigExistsconstraint can do, which is why I associated this change record with this issue.It also means I was able to remove the new
EntityExistsconstraint that @Eli-T proposed. I think that would be an excellent addition, but such a useful general addition is not a hard blocker for this issue. There's now two distinct issues that would benefit from that expansion in capability forConfigExists, so went ahead with that.What's still missing is test coverage.
\Drupal\Tests\filter\Functional\FilterAdminTest::testFilterAdmin()does some testing offilter.settings, so is the closest place we have.Comment #21
wim leersAha … the reason
Drupal.Tests.config.Functional.ConfigImportAllTestis not passing tests is actually quite simple:filter.settingsis simple configfilter.settingsis installed/saved, text format config entities have not yet been installedConfigImportAllTest::testInstallUninstall()fails.There is the short-term solution and the long-term one:
filter.settings:fallback_formatand instead add ais_fallbackproperty toFilterFormatconfig entities?(But how to then guarantee only one of these is marked as the fallback without introducing a race condition there? 🤔)
Because there is no clear long-term solution either, I think the short-term solution is fine for now.
Comment #22
smustgrave commentedLeft a small comment, let me know what you think.
Comment #23
wim leersThis flaw in
filter.settingswas introduced in #1799440: Convert Filter variables to Configuration System.#1932544: Remove all traces of fallback format concept from the (admin) UI is the long-term solution.
Updated comment 👍
Comment #25
catchCommitted/pushed to 11.x, thanks!
Comment #26
wim leers