Problem/Motivation
Sibling issue for config entities: #2869792: [meta] Add constraints to all config entity types.
Similar as we want to expose UPDATE functionality for config entities, (see #2869792: [meta] Add constraints to all config entity types / #2300677: JSON:API POST/PATCH support for fully validatable config entities) we want to also add support for simple configuration, see #2911319: Provide a single command to install & run Drupal / #2949888: Enhance config schema for richer default experiences).
In order to safely expose configuration entities we need to add constrains to simple configurations, like the system.site configuration.
Proposed resolution
Add validation to all simple config in core.
- Find all non-test
type: config_objectoccurrences in Drupal core:
grep -r --include=\*.schema.yml --exclude=*/tests/* 'type: config_object' ./core - There's 50 in
11.xon Apr 29, 2024 👆:
$ grep -r --include=\*.schema.yml --exclude=*/tests/* 'type: config_object' ./core | wc -l 50 - In the Standard install profile, there's 38:
$ ./vendor/bin/drush ev "print count(array_filter(\Drupal::service('config.typed')->getDefinitions(), fn (array \$def) => (\$def['type'] ?? '') === 'config_object'))" 38 - of which (currently) 22 are fully validatable:
$ ./vendor/bin/drush ev "print count(array_filter(\Drupal::service('config.typed')->getDefinitions(), fn (array \$def) => (\$def['type'] ?? '') === 'config_object' && array_key_exists('FullyValidatable', \$def['constraints'] ?? [])))" 22
Remaining tasks
So let's generate a TODO list for us:
./vendor/bin/drush ev "\$simple = array_filter(\Drupal::service('config.typed')->getDefinitions(), fn (array \$def) => (\$def['type'] ?? '') === 'config_object'); print implode(\"\n\", array_map(fn (\$name, \$def) => '<li>' . ((array_key_exists('FullyValidatable', \$def['constraints'] ?? [])) ? '✅' : '') . '<code>' . \$name .'
', array_keys(\$simple), array_values(\$simple)))"
The output of 👆 copy/pasted into this issue summary:
theme_settings- ✅
core.extension core.menu.static_menu_link_overrides- ✅
announcements_feed.settings - ✅
automated_cron.settings - ✅
comment.settings - ✅
contact.settings - ✅
dblog.settings - ✅
field.settings - ✅
field_ui.settings file.settings- ✅
filter.settings - ✅
image.settings - ✅
menu_ui.settings - ✅
node.settings - ✅
search.settings system.site- ✅
system.maintenance - ✅
system.cron - ✅
system.date - ✅
system.diff - ✅
system.logging system.performancesystem.themesystem.file- ✅
system.image - ✅
system.image.gd - ✅
system.mail - ✅
system.advisories - ✅
system.feature_flags - ✅
taxonomy.settings - ✅
text.settings - ✅
update.settings - ✅
user.settings - ✅
user.mail user.floodviews.settings
(See the Child issues
in the sidebar to find the issues for the not-yet-validatable ones.)
Total: 22/50 = 44%
Standard: 22/38 = 58%
Last updated: April 29, 2024.
User interface changes
None.
API changes
None.
Data model changes
None.
Comments
Comment #2
dawehnerComment #3
dawehnerComment #4
dawehnerComment #5
gabesulliceComment #6
wim leersComment #7
wim leers#2969065: Use typed config validation constraints for validation of cdn.settings simple config is an example in contrib that I worked on.
Comment #10
wim leers#2969065: Use typed config validation constraints for validation of cdn.settings simple config landed; the CDN module in contrib now has configuration validation for its simple config.
Comment #11
wim leers(And #2870435: Support additional stream wrappers just added another validation constraint for a new config key-value pair.)
Comment #12
geek-merlinThis is exciting. I'll love to adopt this.
Comment #21
wim leersWe're well on our way now.
See https://www.drupal.org/node/3404425. Thanks to #3391990: Automated report on core config validatability and #3412551: Improve #3391990: add % labels, surface (fully) validatable object counts, debug the sudden decline post we now know automatically which are the currently fully validatable
Among those, there are currently zero simple config objects. But #3412084: Follow-up for #3364109: opt in already validatable simple config to FullyValidatable is changing that, because we have multiple fully validatable simple config that simply has not yet been marked as such because the API did not exist yet.
Once #3412084: Follow-up for #3364109: opt in already validatable simple config to FullyValidatable lands, these 6 simple config are explicitly fully validatable (they already are today):
comment.settingsmenu_ui.settingsnode.settingssystem.maintenancesystem.feature_flagstaxonomy.settingsHowever, this issue still surfaced one additional need not yet met: a definition of done. I think that the definition here is: all
type: config_objectsubtypes in Drupal core must have theFullyValidatableconstraint on them.Before creating that listing by hand, let's first focus on the simple config that is part of the Standard install profile. That's what https://project.pages.drupalcode.org/config_inspector/ is currently visualizing.
Comment #22
wim leersComment #23
wim leers#3412084: Follow-up for #3364109: opt in already validatable simple config to FullyValidatable landed!
Comment #24
wim leersHad some fun with
drushand theconfig.typedservice to semi-automate keeping this plan issue up-to-date 😊Comment #25
wim leersOops, that was done against #3422862: Add validation constraints to book.settings 😅
Rather than listing explicit issues in the summary, please see the child issues in the sidebar — that makes it easier to keep this up-to-date.
Comment #26
wim leersCore just gained new simple config:
layout_builder.settingswas added in #3043330: Reduce the number of field blocks created for entities (possibly to zero) and being marked validatable in #3426429: Mark layout_builder.settings fully validatable.Comment #27
wim leersLast update of IS was on Feb 21. Updated for current state 👍
Comment #28
wim leersUpdated stats in the issue summary again. Big bump! 🥳
Comment #29
phenaproximaComment #30
wim leersExactly half of Standard's simple config is now fully validatable!
Comment #31
wim leers#3417363: Add validation constraints to field_ui.settings landed!
Comment #32
narendrarsdc_tags.settingsin above list does not seems to be part of core.Comment #33
wim leers#32: You're right! This was due to a contrib module I was testing. Apologies, fixed that!
In the mean time, two more have landed:
Comment #34
phenaproxima#3436632: Add validation constraints to system.logging is in.
Comment #35
bbralaComment #36
bbrala#3436096: Add validation constraints to system.file landed.
Comment #37
bbrala#3441434: Add validation constraints to core.menu.schema.yml landed.
Comment #38
bbrala#3432353: Add validation constraints to core.extension landed