Problem/Motivation

Once #3364109: Configuration schema & required values: add test coverage for `nullable: true` validation support lands, MANY (most!) config schema data types will automatically get the NotNull validation constraint.

But … that still is not sufficient validation.

Steps to reproduce

With Config Inspector's latest release, #3364109: Configuration schema & required values: add test coverage for `nullable: true` validation support will show:

$ vendor/bin/drush config:inspect --filter-keys system.date --detail --strict-validation --list-constraints
 Legend for Data: 
  ✅❓  → Correct primitive type, detailed validation impossible.
  ✅✅  → Correct primitive type, passed all validation constraints.
 ----------------------------------------- --------- ------------- ------ ------------------------------ 
  Key                                       Status    Validatable   Data   Validation constraints        
 ----------------------------------------- --------- ------------- ------ ------------------------------ 
  system.date                               Correct   100%          ✅✅   ValidKeys: '<infer>'          
                                                                           ↣ NotNull: {  }               
   system.date:                             Correct   Validatable   ✅✅   ValidKeys: '<infer>'          
                                                                           ↣ NotNull: {  }               
   system.date:_core                        Correct   Validatable   ✅✅   ValidKeys:                    
                                                                             - default_config_hash       
                                                                           ↣ NotNull: {  }               
   system.date:_core.default_config_hash    Correct   Validatable   ✅✅   NotNull: {  }                 
                                                                           Regex: '/^[a-zA-Z0-9\-_]+$/'  
                                                                           Length: 43                    
                                                                           ↣ PrimitiveType: {  }         
   system.date:country                      Correct   Validatable   ✅✅   ValidKeys: '<infer>'          
                                                                           ↣ NotNull: {  }               
   system.date:country.default              Correct   Validatable   ✅✅   ↣ PrimitiveType: {  }         
                                                                           ↣ NotNull: {  }               
   system.date:first_day                    Correct   Validatable   ✅✅   ↣ PrimitiveType: {  }         
                                                                           ↣ NotNull: {  }               
   system.date:timezone                     Correct   Validatable   ✅✅   ValidKeys: '<infer>'          
                                                                           ↣ NotNull: {  }               
   system.date:timezone.default             Correct   Validatable   ✅✅   ↣ PrimitiveType: {  }         
                                                                           ↣ NotNull: {  }               
   system.date:timezone.user                Correct   Validatable   ✅✅   ValidKeys: '<infer>'          
                                                                           ↣ NotNull: {  }               
   system.date:timezone.user.configurable   Correct   Validatable   ✅✅   ↣ PrimitiveType: {  }         
                                                                           ↣ NotNull: {  }               
   system.date:timezone.user.default        Correct   Validatable   ✅✅   ↣ PrimitiveType: {  }         
                                                                           ↣ NotNull: {  }               
   system.date:timezone.user.warn           Correct   Validatable   ✅✅   ↣ PrimitiveType: {  }         
                                                                           ↣ NotNull: {  }               
 ----------------------------------------- --------- ------------- ------ ------------------------------ 

This is invalid.

Proposed resolution

Require more than PrimitiveType AND more than NotNull! That should lead to:

$ vendor/bin/drush config:inspect --filter-keys system.date --detail --strict-validation --list-constraints
 Legend for Data: 
  ✅❓  → Correct primitive type, detailed validation impossible.
  ✅✅  → Correct primitive type, passed all validation constraints.
 ----------------------------------------- --------- ------------- ------ ------------------------------ 
  Key                                       Status    Validatable   Data   Validation constraints        
 ----------------------------------------- --------- ------------- ------ ------------------------------ 
  system.date                               Correct   67%           ✅❓   ValidKeys: '<infer>'          
                                                                           ↣ NotNull: {  }               
   system.date:                             Correct   Validatable   ✅✅   ValidKeys: '<infer>'          
                                                                           ↣ NotNull: {  }               
   system.date:_core                        Correct   Validatable   ✅✅   ValidKeys:                    
                                                                             - default_config_hash       
                                                                           ↣ NotNull: {  }               
   system.date:_core.default_config_hash    Correct   Validatable   ✅✅   NotNull: {  }                 
                                                                           Regex: '/^[a-zA-Z0-9\-_]+$/'  
                                                                           Length: 43                    
                                                                           ↣ PrimitiveType: {  }         
   system.date:country                      Correct   Validatable   ✅✅   ValidKeys: '<infer>'          
                                                                           ↣ NotNull: {  }               
   system.date:country.default              Correct   NOT           ✅❓                                 
   system.date:first_day                    Correct   NOT           ✅❓                                 
   system.date:timezone                     Correct   Validatable   ✅✅   ValidKeys: '<infer>'          
                                                                           ↣ NotNull: {  }               
   system.date:timezone.default             Correct   NOT           ✅❓                                 
   system.date:timezone.user                Correct   Validatable   ✅✅   ValidKeys: '<infer>'          
                                                                           ↣ NotNull: {  }               
   system.date:timezone.user.configurable   Correct   Validatable   ✅✅   ↣ PrimitiveType: {  }         
                                                                           ↣ NotNull: {  }               
   system.date:timezone.user.default        Correct   NOT           ✅❓                                 
   system.date:timezone.user.warn           Correct   Validatable   ✅✅   ↣ PrimitiveType: {  }         
                                                                           ↣ NotNull: {  }               
 ----------------------------------------- --------- ------------- ------ ------------------------------ 

Remaining tasks

TBD

User interface changes

None.

API changes

None.

Data model changes

None.

CommentFileSizeAuthor
#2 3379741-2.patch1.17 KBwim leers

Comments

Wim Leers created an issue. See original summary.

wim leers’s picture

Assigned: Unassigned » wim leers
Status: Active » Needs review
StatusFileSize
new1.17 KB
wim leers’s picture

Title: Update ConfigInspectorManager::getNodeConstraints() for #3364109 » Update ConfigInspectorManager::getNodeConstraints() for #3364109: NotNull + PrimitiveType is insufficient validation
Assigned: wim leers » Unassigned
Status: Needs review » Reviewed & tested by the community

Tested again, and verified that #3364108: Configuration schema & required keys does not need yet another addition 👍

  • Wim Leers committed fc63f8fa on 2.1.x
    Issue #3379741 by Wim Leers: Update ConfigInspectorManager::...
wim leers’s picture

Status: Reviewed & tested by the community » Fixed

Status: Fixed » Closed (fixed)

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