Problem/Motivation
Sibling issue for simple config: #2952037: [meta] Add constraints to all simple configuration.
Now that we have the possibilities to validate configuration we should do that.
This meta issue is about adding constrains to all config entities, so we can use that in JSON:API as well as in configuration entity forms.
The current list of config entity types in core:
core.base_field_override.*.*.*: #3324140: Convert field_storage_config and field_config's form validation logic to validation constraintsfield.field.*.*.*: #3324140: Convert field_storage_config and field_config's form validation logic to validation constraints- ✅
core.date_format.*: #3397491: Add validation constraints to core.date_format.* core.entity_view_mode.*.*: #3445150: Add validation constraints to core.entity_view_mode.*.*core.entity_view_display.*.*.*- ✅
core.entity_form_mode.*.*:#3448457: Add validation constraints to core.entity_form_mode.*.* core.entity_form_display.*.*.*- ✅
block.block.*: #3379725: Make Block config entities fully validatable - ✅
block_content.type.*: #3397493: Add validation constraints to block_content.type.* comment.type.*: #3455066: Add validation constraints to comment.type.*- ✅
editor.editor.*: #3412361: Mark Editor config schema as fully validatable field.storage.*.*: #3324140: Convert field_storage_config and field_config's form validation logic to validation constraintsfilter.format.*: #3421946: [PP-2] Make FilterFormat config entities fully validatable- ✅
image.style.*: #3447286: Add validation constraints to image.style.* - ✅
language.entity.*#3457766: Add validation constraints to language.entity.*Not inStandard - ✅
language.content_settings.*.*#3458321: Add validation constraints to language.content_settings.*.* Not inStandard - ✅
node.type.*: #3379091: Make NodeType config entities fully validatable responsive_image.styles.*Not inStandardrest.resource.*Not inStandard- ✅
search.page.*: #3456133: Add validation constraints to search.page.* - ✅
shortcut.set.*— see #3324984-35: Create test that reports % of config entity types (and config schema types) that is validatable - ✅
system.menu.*— see #3324984-35: Create test that reports % of config entity types (and config schema types) that is validatable - ✅
system.action.*:#3449259: Add validation constraints to system.action.* - ✅
taxonomy.vocabulary.*: #2002174: Allow vocabularies to be validated via the API, not just during form submissions - ✅
user.role.*: #3445215: Add validation constraints to user.role.* views.view.*workflows.workflow.*: #2920441: Add config validation for workflow entities Not inStandard
Total: 13/28=46%
Standard: 11/23=48%
Last updated: July 23, 2024.
Related issues
For all config entity types: UUID: #2870878: Add config validation for UUIDsFor all config entity types: machine_name: #2920678: Add config validation for the allowed characters of machine namesFor all config entity types: plugin IDs: #2920682: Add config validation for plugin IDs
Comments
Comment #2
dawehnerHere is a suggestion how we can split up the work in some reasonable sized junks:
Comment #3
dawehnerComment #4
wim leersComment #5
dawehnerAdded a related issue which ideally we fix first: #2869809: Make it easy to get typed config representations of entities to make testing it easier.
Comment #6
tstoecklerSo I guess this is not as interesting to the Rest folks, and I guess should be a (single ?) separate issue, anyway, but we should add constraints to simple (i.e. non-config-entity) configuration, as well, I guess.
Comment #7
dawehnerOh good point, I'm wondering whether we should integrate the constrains into methods as well?
Comment #8
tstoecklerCan you clarify #7? Not sure what you mean by "methods". We already have
ConfigInterface::save($has_trusted_data)so we could to config validation if$has_trusted_dataisFALSE, but that would be kind of a behavior change as that is currently the default.Comment #9
dawehnerNo idea what I was smoking.
Yeah that is a good idea. Wherever we apply config schema validation we should apply config constrain validation as well.
Comment #10
dawehnerI started with a small subissue: #2870878: Add config validation for UUIDs
Comment #11
wim leers#2870878: Add config validation for UUIDs landed!
Comment #12
wim leersWe said at #2300677-115: JSON:API POST/PATCH support for fully validatable config entities.15 that this can happen in parallel with that. But I'm actually not entirely sure that that makes sense — without the ability to add REST test coverage, I'm not sure how much can be done in this issue's child issues?
Comment #13
dawehnerWell, we could totally write test coverage for those constraints. To be honest I think its even much easier to wrote those constrains instead of writing REST level tests.
Comment #14
wim leersWFM :)
Comment #16
wim leersComment #17
wim leersComment #18
sam152 commentedI've created #2920441: Add config validation for workflow entities to cover the workflow config entity. I think given we're doing a lot of validation at the API level, it'll be an interesting challenge to try and cover these same scenarios as constraints and might serve as a road-test of the API in preparation for #2300677: JSON:API POST/PATCH support for fully validatable config entities.
Comment #19
sam152 commentedComment #20
sam152 commentedComment #21
dawehner@Sam152
Comment #22
sam152 commentedThat looks better, thanks.
Comment #23
sam152 commentedComment #24
sam152 commentedThe first property to validate was the ID, which applies to lots of entity types. Adding to the list of generic validations.
Comment #25
sam152 commentedNext cab off the rank is also something which I think is generic.
Comment #27
effulgentsia commentedPromoting this to Major, because it's a blocker to #2300677: JSON:API POST/PATCH support for fully validatable config entities.
Comment #32
simeI was looking at using configuration constraints based on what I see in system.sites.yml:
I experimented with this type of configuration for the site uuid, and for the site name and I was unable to trigger and validation errors. I tried setting values in the UI, config import/export and drush config-set.
Is that a not fully implemented feature? Or is this "constraints:" setting being used in a way that is not obvious? I realise this issue is about config entities, but it seems a good place to discuss since the IS links to the issue that introduced that
Uuid: []line.Comment #38
wim leersI only now re-discovered this issue 😬
See #2164373-34: [META] Untie config validation from form validation — enables validatable Recipes, decoupled admin UIs … for a summary of the progress in the last month. And also especially see #3324984: Create test that reports % of config entity types (and config schema types) that is validatable, where it becomes possible to automatically track how much work remains!
I think we should consider closing this in favor of #2164373.
Thoughts?
Comment #40
wim leersActually, #2164373 is getting impractically broad. Let's keep this for coordinating for config entity types.
Comment #41
wim leersThis blocks #2300677 — see #2300677-258: JSON:API POST/PATCH support for fully validatable config entities.
Comment #42
wim leersGreat news!
Per #3324984-35: Create test that reports % of config entity types (and config schema types) that is validatable,
system.menu.*andshortcut.set.*are done!They look like this:
and:
They are very simple config entity types for sure, but … hey, we've got to start somewhere! 😊
EDIT: this means #2300677 is unblocked, see #2300677-260: JSON:API POST/PATCH support for fully validatable config entities 🚀
Comment #43
borisson_Comment #44
wim leersComment #45
wim leersComment #46
wim leersComment #47
wim leersComment #48
wim leersComment #49
wim leersSince #42: one more landed (
DateFormat), two more in progress (EditorandVocabulary)!Comment #50
wim leersRDF is removed. Test-only config entity types do not necessarily need this IMHO. Let's tighten the scope to config entity types that are actually used in this meta.
Comment #51
wim leersForgot that
BlockContentTypealso landed!Comment #52
wim leersComment #53
wim leersI got #2920441: Add config validation for workflow entities started too — now 100% of the issues listed in the issue summary have an in-progress MR, some RTBC, some nearly, some with still a long way to go.
Progress! 😊
Comment #54
wim leers#2002174: Allow vocabularies to be validated via the API, not just during form submissions landed! 🚢
Comment #55
wim leers#3412361: Mark Editor config schema as fully validatable landed!
Comment #56
wim leers#3379725: Make Block config entities fully validatable is moving forward — probably one of the most important config entity types to make validatable because most sites have a fairly large number of these.
Comment #57
wim leersThe list has gotten shorter thanks to #3422600: Remove Tour module 🤓
Comment #58
wim leersCleaned up, and now with detailed statistics:
Total: 7/28=25%
Standard: 7/23=30%
(just like the sibling issue #2952037: [meta] Add constraints to all simple configuration)
Comment #59
narendrarComment #60
narendrarComment #61
narendrarComment #62
wim leersimage.style.*is in!Comment #63
mtiftComment #64
narendrarComment #65
narendrarComment #66
narendrarComment #67
wim leers3 more config entity types are now fully validatable! 🚀
Comment #68
phenaproxima#3379725: Make Block config entities fully validatable is in!
Comment #69
phenaproxima#3458321: Add validation constraints to language.content_settings.*.* landed!
Comment #70
wim leersUpdating for #68 + #69.
Comment #71
bbralaWhen working on #2300677: JSON:API POST/PATCH support for fully validatable config entities i did notice after actually enabling tests for all validatable config entities, that although
system.action.*is validated, the plugins aren't. So when testing, usinguser_unblock_user_actionit errors on that fact.Not sure if would have marked action as validatable when the configuration you might be able to put in there (from core) is not.
Comment #72
borisson_Well, system.action.* is fully validatable, but you are right that the plugins aren't.
Depending on the metric you use, all the config in core is at around 42% validatability. https://project.pages.drupalcode.org/config_inspector/
So, if we would have to keep all the plugins in mind as well, I think we would probably have to remove even more of the checkmarks from this list. I don't think we have open issues for all the plugins, but I guess we can create those issues to make the plugin validatable again.
Comment #73
bbralaComment #74
bbrala#3508308: Validate system.action.*: add new Constraint RoleExists was merged
Comment #75
bbrala#3448457: Add validation constraints to core.entity_form_mode.*.* is in :)
Comment #77
borisson_Removed contact from the list, now that's no longer in core.