Problem/Motivation
Image style configuration entity is not yet fully validatable:
vendor/bin/drush config:inspect --filter-keys=image.style.large --detail --list-constraints
β π€ Analyzingβ¦
Legend for Data:
β
β β Correct primitive type, detailed validation impossible.
β
β
β Correct primitive type, passed all validation constraints.
-------------------------------------------------------------------------------- --------- ------------- ------ ---------------------------------------------------------------------------------------------
Key Status Validatable Data Validation constraints
-------------------------------------------------------------------------------- --------- ------------- ------ ---------------------------------------------------------------------------------------------
image.style.large Correct 83% β
β ValidKeys: '<infer>'
image.style.large: Correct Validatable β
β
ValidKeys: '<infer>'
image.style.large:_core Correct Validatable β
β
ValidKeys:
- default_config_hash
image.style.large:_core.default_config_hash Correct Validatable β
β
NotNull: { }
Regex: '/^[a-zA-Z0-9\-_]+$/'
Length: 43
β£ PrimitiveType: { }
image.style.large:dependencies Correct Validatable β
β
ValidKeys: '<infer>'
image.style.large:effects Correct NOT β
β β οΈ @todo Add validation constraints to config entity type: image.style.*
image.style.large:effects.6e8fe467-84c1-4ef0-a73b-7eccf1cc20e8 Correct Validatable β
β
ValidKeys: '<infer>'
image.style.large:effects.6e8fe467-84c1-4ef0-a73b-7eccf1cc20e8.data Correct Validatable β
β
ValidKeys: '<infer>'
image.style.large:effects.6e8fe467-84c1-4ef0-a73b-7eccf1cc20e8.data.extension Correct NOT β
β β @todo Add validation constraints to ancestor type: image.effect.image_convert
image.style.large:effects.6e8fe467-84c1-4ef0-a73b-7eccf1cc20e8.id Correct Validatable β
β
PluginExists:
manager: plugin.manager.image.effect
interface: Drupal\image\ImageEffectInterface
β£ PrimitiveType: { }
image.style.large:effects.6e8fe467-84c1-4ef0-a73b-7eccf1cc20e8.uuid Correct Validatable β
β
Uuid: { }
β£ PrimitiveType: { }
image.style.large:effects.6e8fe467-84c1-4ef0-a73b-7eccf1cc20e8.weight Correct Validatable β
β
Range:
min: -2147483648
max: 2147483647
FullyValidatable: null
β£ PrimitiveType: { }
image.style.large:effects.ddd73aa7-4bd6-4c85-b600-bdf2b1628d1d Correct Validatable β
β
ValidKeys: '<infer>'
image.style.large:effects.ddd73aa7-4bd6-4c85-b600-bdf2b1628d1d.data Correct Validatable β
β
ValidKeys: '<infer>'
image.style.large:effects.ddd73aa7-4bd6-4c85-b600-bdf2b1628d1d.data.height Correct NOT β
β β @todo Add validation constraints to ancestor type: image.effect.image_scale
image.style.large:effects.ddd73aa7-4bd6-4c85-b600-bdf2b1628d1d.data.upscale Correct Validatable β
β
β£ PrimitiveType: { }
image.style.large:effects.ddd73aa7-4bd6-4c85-b600-bdf2b1628d1d.data.width Correct NOT β
β β @todo Add validation constraints to ancestor type: image.effect.image_scale
image.style.large:effects.ddd73aa7-4bd6-4c85-b600-bdf2b1628d1d.id Correct Validatable β
β
PluginExists:
manager: plugin.manager.image.effect
interface: Drupal\image\ImageEffectInterface
β£ PrimitiveType: { }
image.style.large:effects.ddd73aa7-4bd6-4c85-b600-bdf2b1628d1d.uuid Correct Validatable β
β
Uuid: { }
β£ PrimitiveType: { }
image.style.large:effects.ddd73aa7-4bd6-4c85-b600-bdf2b1628d1d.weight Correct Validatable β
β
Range:
min: -2147483648
max: 2147483647
FullyValidatable: null
β£ PrimitiveType: { }
image.style.large:label Correct Validatable β
β
Regex:
pattern: '/([^\PC])/u'
match: false
message: 'Labels are not allowed to span multiple lines or contain control characters.'
NotBlank: { }
β£ PrimitiveType: { }
image.style.large:langcode Correct Validatable β
β
NotNull: { }
Choice:
callback: 'Drupal\Core\TypedData\Plugin\DataType\LanguageReference::getAllValidLangcodes'
β£ PrimitiveType: { }
image.style.large:name Correct Validatable β
β
Regex:
pattern: '/^[a-z0-9_]+$/'
message: 'The %value machine name is not valid.'
Length:
max: 166
β£ PrimitiveType: { }
image.style.large:status Correct Validatable β
β
β£ PrimitiveType: { }
image.style.large:uuid Correct Validatable β
β
Uuid: { }
β£ PrimitiveType: { }
-------------------------------------------------------------------------------- --------- ------------- ------ ---------------------------------------------------------------------------------------------
Steps to reproduce
- Get a local git clone of Drupal core
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/drush
vendor/bin/drush config:inspect --filter-keys=image.style.large --detail --list-constraints
Proposed resolution
Add validation constraints to missing properties.
This 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.
Remaining tasks
User interface changes
None.
API changes
None.
Data model changes
More validation π
Release notes snippet
None.
Comments
Comment #3
narendrarComment #4
smustgrave commentedThought maybe we would need an upgrade path for image effects without weight.
But did a quick check on 11.x and 10.3.x I see that weight is already included so assuming these were just missed test updates.
Rest of the changes look good. Using config inspector on 10.3.x I see all green now too. Attaching screenshot
Comment #6
catchCommitted/pushed to 11.x, thanks!
I don't think this is beta-eligible (e.g. it could break contrib tests that need similar changes) and I don't think it is an obvious candidate for backport to 10.4.x because it's not adding a new API, so leaving in (what will be) 11.1.x for now.