Add validation constraints to system.site

Created on 25 April 2024, 12 months ago
Updated 7 May 2024, 11 months ago

Problem/Motivation

system.site has 5 property path that are not yet validatable:

vendor/bin/drush config:inspect --filter-keys=system.site --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                                                                       
 ---------------------------------------- --------- ------------- ------ --------------------------------------------------------------------------------------------- 
  system.site                              Correct   69%           โœ…โ“   ValidKeys: '<infer>'                                                                         
                                                                          LangcodeRequiredIfTranslatableValues: null                                                   
   system.site:                            Correct   Validatable   โœ…โœ…   ValidKeys: '<infer>'                                                                         
                                                                          LangcodeRequiredIfTranslatableValues: null                                                   
   system.site:_core                       Correct   Validatable   โœ…โœ…   ValidKeys:                                                                                   
                                                                            - default_config_hash                                                                      
   system.site:_core.default_config_hash   Correct   Validatable   โœ…โœ…   NotNull: {  }                                                                                
                                                                          Regex: '/^[a-zA-Z0-9\-_]+$/'                                                                 
                                                                          Length: 43                                                                                   
                                                                          โ†ฃ PrimitiveType: {  }                                                                        
   system.site:admin_compact_mode          Correct   Validatable   โœ…โœ…   โ†ฃ PrimitiveType: {  }                                                                        
   system.site:default_langcode            Correct   Validatable   โœ…โœ…   NotNull: {  }                                                                                
                                                                          Choice:                                                                                      
                                                                            callback: 'Drupal\Core\TypedData\Plugin\DataType\LanguageReference::getAllValidLangcodes'  
                                                                          โ†ฃ PrimitiveType: {  }                                                                        
   system.site:langcode                    Correct   Validatable   โœ…โœ…   NotNull: {  }                                                                                
                                                                          Choice:                                                                                      
                                                                            callback: 'Drupal\Core\TypedData\Plugin\DataType\LanguageReference::getAllValidLangcodes'  
                                                                          โ†ฃ PrimitiveType: {  }                                                                        
   system.site:mail                        Correct   Validatable   โœ…โœ…   Email:                                                                                       
                                                                            message: '%value is not a valid email address.'                                            
                                                                          โ†ฃ PrimitiveType: {  }                                                                        
   system.site:mail_notification           Correct   NOT           โœ…โ“   โš ๏ธ  @todo Add validation constraints here                                                    
   system.site:name                        Correct   Validatable   โœ…โœ…   Regex:                                                                                       
                                                                            pattern: '/([^\PC])/u'                                                                     
                                                                            match: false                                                                               
                                                                            message: 'Labels are not allowed to span multiple lines or contain control characters.'    
                                                                          โ†ฃ PrimitiveType: {  }                                                                        
   system.site:page                        Correct   Validatable   โœ…โœ…   ValidKeys: '<infer>'                                                                         
   system.site:page.403                    Correct   NOT           โœ…โ“   โš ๏ธ  @todo Add validation constraints here                                                    
   system.site:page.404                    Correct   NOT           โœ…โ“   โš ๏ธ  @todo Add validation constraints here                                                    
   system.site:page.front                  Correct   NOT           โœ…โ“   โš ๏ธ  @todo Add validation constraints here                                                    
   system.site:slogan                      Correct   Validatable   โœ…โœ…   Regex:                                                                                       
                                                                            pattern: '/([^\PC])/u'                                                                     
                                                                            match: false                                                                               
                                                                            message: 'Labels are not allowed to span multiple lines or contain control characters.'    
                                                                          โ†ฃ PrimitiveType: {  }                                                                        
   system.site:uuid                        Correct   Validatable   โœ…โœ…   Uuid: {  }                                                                                   
                                                                          NotNull: {  }                                                                                
                                                                          โ†ฃ PrimitiveType: {  }                                                                        
   system.site:weight_select_max           Correct   NOT           โœ…โ“   โš ๏ธ  @todo Add validation constraints here                                                    
 ---------------------------------------- --------- ------------- ------ --------------------------------------------------------------------------------------------- 

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=system.site --detail --list-constraints

Proposed resolution

Add validation constraints to:

  1. system.site:mail_notification
  2. system.site:page.403
  3. system.site:page.404
  4. system.site:page.front
  5. system.site:weight_select_max

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

Data model changes

More validation ๐Ÿš€

Release notes snippet

None.

๐Ÿ“Œ Task
Status

Active

Version

11.0 ๐Ÿ”ฅ

Component
Systemย  โ†’

Last updated about 21 hours ago

No maintainer
Created by

๐Ÿ‡ฎ๐Ÿ‡ณIndia narendraR Jaipur, India

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Merge Requests

Comments & Activities

  • Issue created by @narendraR
  • ๐Ÿ‡ฎ๐Ÿ‡ณIndia narendraR Jaipur, India
  • Merge request !7723Initial commit โ†’ (Open) created by narendraR
  • Pipeline finished with Failed
    12 months ago
    Total: 1473s
    #156255
  • Pipeline finished with Failed
    12 months ago
    Total: 988s
    #157085
  • Pipeline finished with Failed
    12 months ago
    Total: 1043s
    #157164
  • Pipeline finished with Failed
    12 months ago
    Total: 2949s
    #157342
  • Pipeline finished with Failed
    12 months ago
    Total: 1110s
    #157690
  • Pipeline finished with Failed
    11 months ago
    Total: 990s
    #159591
  • First commit to issue fork.
  • Status changed to Needs review 11 months ago
  • ๐Ÿ‡บ๐Ÿ‡ธUnited States mikelutz Michigan, USA
  • Pipeline finished with Failed
    11 months ago
    Total: 576s
    #166824
  • Status changed to Needs work 11 months ago
  • ๐Ÿ‡บ๐Ÿ‡ธUnited States mikelutz Michigan, USA
  • ๐Ÿ‡บ๐Ÿ‡ธUnited States carsoncho Kansas City, MO

    This all looks correct to me. Config inspector is reporting this at 100% now. Is the reason this is back to Needs work because of the pipelines failing?

  • Pipeline finished with Failed
    11 months ago
    Total: 601s
    #169214
  • Pipeline finished with Failed
    11 months ago
    Total: 674s
    #169923
  • Pipeline finished with Success
    11 months ago
    Total: 650s
    #169953
  • Pipeline finished with Success
    11 months ago
    Total: 609s
    #171370
  • Status changed to Needs review 11 months ago
  • ๐Ÿ‡ฎ๐Ÿ‡ณIndia narendraR Jaipur, India
  • Status changed to RTBC 11 months ago
  • ๐Ÿ‡บ๐Ÿ‡ธUnited States smustgrave

    So applied the MR locally.

    Update hook ran just fine

    I'm still able to update the settings without issue

    The proposed schema changes believe make sense.

    +1 from me.

  • Status changed to Needs work 11 months ago
  • ๐Ÿ‡ณ๐Ÿ‡ฟNew Zealand quietone

    I read the IS and the MR. There are new methods in the MR that should be documented.

  • Status changed to Needs review 11 months ago
  • ๐Ÿ‡บ๐Ÿ‡ธUnited States carsoncho Kansas City, MO

    I've added docblock info for those new methods. Ready for review.

  • Pipeline finished with Failed
    11 months ago
    Total: 168s
    #184215
  • Status changed to Needs work 11 months ago
  • The Needs Review Queue Bot โ†’ tested this issue. It fails the Drupal core commit checks. Therefore, this issue status is now "Needs work".

    This does not mean that the patch necessarily needs to be re-rolled or the MR rebased. Read the Issue Summary, the issue tags and the latest discussion here to determine what needs to be done.

    Consult the Drupal Contributor Guide โ†’ to find step-by-step guides for working with issues.

  • Status changed to Needs review 11 months ago
  • ๐Ÿ‡บ๐Ÿ‡ธUnited States mikelutz Michigan, USA

    Fixed coding standards and rebased to see if the validation checker can resolve updated dependencies.

  • Pipeline finished with Success
    11 months ago
    Total: 499s
    #184313
  • ๐Ÿ‡บ๐Ÿ‡ธUnited States smustgrave

    Left 1 question on the MR.

  • Pipeline finished with Success
    10 months ago
    Total: 598s
    #185664
  • ๐Ÿ‡ฎ๐Ÿ‡ณIndia narendraR Jaipur, India

    Feedback addressed.

  • Status changed to RTBC 10 months ago
  • ๐Ÿ‡บ๐Ÿ‡ธUnited States smustgrave

    Believe feedback has been addressed.

  • Status changed to Needs work 10 months ago
  • ๐Ÿ‡ฌ๐Ÿ‡งUnited Kingdom alexpott ๐Ÿ‡ช๐Ÿ‡บ๐ŸŒ

    I've added some comments to the MR and 1 that I think should have a follow up created for.

  • ๐Ÿ‡ง๐Ÿ‡ชBelgium borisson_ Mechelen, ๐Ÿ‡ง๐Ÿ‡ช

    Followup created: ๐Ÿ“Œ Add PHP_INT_MAX to integer schema configuration Active

  • Pipeline finished with Failed
    9 months ago
    Total: 321s
    #213593
  • Pipeline finished with Failed
    9 months ago
    Total: 401s
    #213679
  • Pipeline finished with Failed
    9 months ago
    Total: 322s
    #213688
  • Pipeline finished with Failed
    9 months ago
    #213703
  • Status changed to Needs review 9 months ago
  • Pipeline finished with Success
    9 months ago
    Total: 898s
    #213792
  • Status changed to RTBC 9 months ago
  • ๐Ÿ‡ฎ๐Ÿ‡ณIndia kunal.sachdev

    Looks good. Just have one minor doubt.

  • Status changed to Needs work 9 months ago
  • ๐Ÿ‡ฌ๐Ÿ‡งUnited Kingdom alexpott ๐Ÿ‡ช๐Ÿ‡บ๐ŸŒ

    removing the UUID constraint feels like a step in the wrong direction. NULL is never really a valid value for site UUID.

  • ๐Ÿ‡บ๐Ÿ‡ธUnited States phenaproxima Massachusetts

    Thanks, @narendraR; that makes sense.

    However, I agree with @alexpott that NULL is never valid for the site UUID, and so it shouldn't be nullable.

  • ๐Ÿ‡ฌ๐Ÿ‡งUnited Kingdom alexpott ๐Ÿ‡ช๐Ÿ‡บ๐ŸŒ

    I think this issue points to us needing a new constraint which is something like NotBlankAfterInstall - so a very can be blank during site install but once the site is up and running it can not be. This is true for uuid, name and email.

    I also think that none of these should be nullable. PHP 8 makes swapping between NULLs and strings hard.

  • Pipeline finished with Failed
    9 months ago
    Total: 455s
    #226496
  • ๐Ÿ‡ฎ๐Ÿ‡ณIndia narendraR Jaipur, India

    @alexpott, I tried to create a new constraint as suggested in #23. But I don't understand how to bypass existingNotNullConstraint for UUID. https://git.drupalcode.org/project/drupal/-/merge_requests/7723/diffs?commit_id=4fcb5099b2b23f22643948c901321db04b89b0db#4d658554b6066a85600dfbe03dc34c3003f8a3e1_0_32

  • ๐Ÿ‡ง๐Ÿ‡ชBelgium borisson_ Mechelen, ๐Ÿ‡ง๐Ÿ‡ช

    I don't understand having to bypass NotNullConstraint? I think we have to reimplement it in here?

    We should probably start with a reroll here.

  • First commit to issue fork.
  • Pipeline finished with Failed
    9 days ago
    Total: 169s
    #461855
  • ๐Ÿ‡ณ๐Ÿ‡ฑNetherlands bbrala Netherlands

    Rebased thsi issue.

    @alexpott

    > I think this issue points to us needing a new constraint which is something like NotBlankAfterInstall - so a very can be blank during site install but once the site is up and running it can not be. This is true for uuid, name and email.

    You say this, which is kinda the same problem as ๐Ÿ“Œ Add validation constraints to contact.form.* Needs work comment #32. There it is a recipe which wants to use mail to replace a value, which is doesn't get since mail is not yet in config when installing from a recipe with the drupal command.

    So there is also some sort of 'during install' issue, where during an install is appearantly possible to have invalid config.

    Perhaps we even need to fix it ealier? Although i don't really feal like ignoring validation for config while installing is a good idea. Since it is pretty valuable, what if you are to install some sort of Drupal implementation (like a decoupled Drupal) and it comes with invalid config, would we want to ignore that?

  • Pipeline finished with Failed
    9 days ago
    Total: 870s
    #461862
Production build 0.71.5 2024