Problem/Motivation

ContentLanguageSettings entity is not yet fully validatable:

.vendor/bin/drush config:inspect --filter-keys=language.content_settings.node.article --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                                                                       
 ------------------------------------------------------------------------------------------ --------- ------------- ------ --------------------------------------------------------------------------------------------- 
  language.content_settings.node.article                                                     Correct   74%           ✅❓   ValidKeys: '<infer>'                                                                         
   language.content_settings.node.article:                                                   Correct   Validatable   ✅✅   ValidKeys: '<infer>'                                                                         
   language.content_settings.node.article:_core                                              Correct   Validatable   ✅✅   ValidKeys:                                                                                   
                                                                                                                              - default_config_hash                                                                      
   language.content_settings.node.article:_core.default_config_hash                          Correct   Validatable   ✅✅   NotNull: {  }                                                                                
                                                                                                                            Regex: '/^[a-zA-Z0-9\-_]+$/'                                                                 
                                                                                                                            Length: 43                                                                                   
                                                                                                                            ↣ PrimitiveType: {  }                                                                        
   language.content_settings.node.article:default_langcode                                   Correct   Validatable   ✅✅   Choice:                                                                                      
                                                                                                                              callback: '\Drupal\language\Entity\ContentLanguageSettings::getAllValidDefaultLangcodes'   
                                                                                                                            ↣ PrimitiveType: {  }                                                                        
                                                                                                                            ↣ NotNull: {  }                                                                              
   language.content_settings.node.article:dependencies                                       Correct   Validatable   ✅✅   ValidKeys: '<infer>'                                                                         
   language.content_settings.node.article:dependencies.config                                Correct   NOT           ✅❓   ❌ @todo Add validation constraints to ancestor type: config_dependencies                    
   language.content_settings.node.article:dependencies.config.0                              Correct   Validatable   ✅✅   NotBlank: {  }                                                                               
                                                                                                                            ConfigExists: {  }                                                                           
                                                                                                                            ↣ PrimitiveType: {  }                                                                        
   language.content_settings.node.article:dependencies.module                                Correct   NOT           ✅❓   ❌ @todo Add validation constraints to ancestor type: config_dependencies                    
   language.content_settings.node.article:dependencies.module.0                              Correct   Validatable   ✅✅   NotBlank: {  }                                                                               
                                                                                                                            ExtensionName: {  }                                                                          
                                                                                                                            ExtensionExists: module                                                                      
                                                                                                                            ↣ PrimitiveType: {  }                                                                        
   language.content_settings.node.article:id                                                 Correct   NOT           ✅❓   ⚠️  @todo Add validation constraints to config entity type: language.content_settings.*.*    
   language.content_settings.node.article:langcode                                           Correct   Validatable   ✅✅   NotNull: {  }                                                                                
                                                                                                                            Choice:                                                                                      
                                                                                                                              callback: 'Drupal\Core\TypedData\Plugin\DataType\LanguageReference::getAllValidLangcodes'  
                                                                                                                            ↣ PrimitiveType: {  }                                                                        
   language.content_settings.node.article:language_alterable                                 Correct   Validatable   ✅✅   ↣ PrimitiveType: {  }                                                                        
   language.content_settings.node.article:status                                             Correct   Validatable   ✅✅   ↣ PrimitiveType: {  }                                                                        
   language.content_settings.node.article:target_bundle                                      Correct   Validatable   ✅✅   EntityBundleExists: '%parent.target_entity_type_id'                                          
                                                                                                                            ↣ PrimitiveType: {  }                                                                        
   language.content_settings.node.article:target_entity_type_id                              Correct   NOT           ✅❓   ⚠️  @todo Add validation constraints to config entity type: language.content_settings.*.*    
   language.content_settings.node.article:third_party_settings                               Correct   NOT           ✅❓   ⚠️  @todo Add validation constraints to config entity type: language.content_settings.*.*    
   language.content_settings.node.article:third_party_settings.content_translation           Correct   Validatable   ✅✅   ValidKeys: '<infer>'                                                                         
   language.content_settings.node.article:third_party_settings.content_translation.enabled   Correct   Validatable   ✅✅   ↣ PrimitiveType: {  }                                                                        
   language.content_settings.node.article: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. Install Demo: Umami profile./vendor/bin/drush si demo_umami -y
  5. vendor/bin/drush config:inspect --filter-keys=language.content_settings.node.article --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 #recipes.

Remaining tasks

MR

User interface changes

None.

API changes

None.

Data model changes

More validation 🚀

Release notes snippet

None.

Issue fork drupal-3458321

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
new108.49 KB

On a standard profile install of 11.x
With configuration inspector and MR applied I get all green

green

alexpott’s picture

Status: Reviewed & tested by the community » Needs work

We should add test coverage of ContentLanguageSettings::validateId()

narendrar’s picture

Status: Needs work » Needs review
smustgrave’s picture

Status: Needs review » Reviewed & tested by the community

Then believe feedback has been addressed :)

  • longwave committed 6fc96204 on 10.4.x
    Issue #3458321 by narendraR, smustgrave, alexpott: Add validation...

  • longwave committed ac88e9a4 on 11.x
    Issue #3458321 by narendraR, smustgrave, alexpott: Add validation...
longwave’s picture

Version: 11.x-dev » 10.4.x-dev
Status: Reviewed & tested by the community » Fixed

Committed to 11.1.x and 10.4.x, this isn't a bug fix or critical task so not eligible for backport to 11.0.x or 10.3.x

Committed and pushed ac88e9a4d8 to 11.x and 6fc96204f7 to 10.4.x. Thanks!

Status: Fixed » Closed (fixed)

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