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

  1. Get a local git clone of Drupal core 11.x.
  2. 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!)
  3. composer require drush/drush
  4. 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.

Issue fork drupal-3447286

Command icon Show commands

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

narendraR created an issue. See original summary.

narendrar’s picture

Status: Needs work Β» Needs review
smustgrave’s picture

Status: Needs review Β» Reviewed & tested by the community
StatusFileSize
new82.78 KB

Thought 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

validation

  • catch committed 33143c7c on 11.x
    Issue #3447286 by narendraR, smustgrave: Add validation constraints to...
catch’s picture

Status: Reviewed & tested by the community Β» Fixed

Committed/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.

Status: Fixed Β» Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.