Add validation constraints to contact.settings

Created on 9 April 2024, about 1 year ago

Problem/Motivation

The User module's flood have 4 property paths that are not yet validatable:

vendor/bin/drush config:inspect --filter-keys=user.flood  --detail --list-constraints  --fields=key,validatability,constraints
โžœ  ๐Ÿค– Analyzingโ€ฆ

 --------------------- ------------- ------------------------------------- 
  Key                   Validatable   Validation constraints               
 --------------------- ------------- ------------------------------------- 
  user.flood            50%           ValidKeys: '<infer>'                 
   user.flood:          Validatable   ValidKeys: '<infer>'                 
   user.flood:_core     Validatable   ValidKeys:                           
                                        - default_config_hash              
   user.flood:_core.d   Validatable   NotNull: {  }                        
  efault_config_hash                  Regex: '/^[a-zA-Z0-9\-_]+$/'         
                                      Length: 43                           
                                      โ†ฃ PrimitiveType: {  }                
   user.flood:ip_limi   NOT           โš ๏ธ  @todo Add validation constraints  
  t                                   here                                 
   user.flood:ip_wind   NOT           โš ๏ธ  @todo Add validation constraints  
  ow                                  here                                 
   user.flood:uid_onl   Validatable   โ†ฃ PrimitiveType: {  }                
  y                                                                        
   user.flood:user_li   NOT           โš ๏ธ  @todo Add validation constraints  
  mit                                 here                                 
   user.flood:user_wi   NOT           โš ๏ธ  @todo Add validation constraints  
  ndow                                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=user.flood --detail --list-constraints

Proposed resolution

  1. Add validation constraints.
  2. Mark FullyValidatable.

Remaining tasks

User interface changes

API changes

Data model changes

Release notes snippet

๐Ÿ“Œ Task
Status

Active

Version

11.0 ๐Ÿ”ฅ

Component
User moduleย  โ†’

Last updated 2 days ago

Created by

๐Ÿ‡ฎ๐Ÿ‡ณIndia kunal.sachdev

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

Comments & Activities

  • Issue created by @kunal.sachdev
  • ๐Ÿ‡ง๐Ÿ‡ชBelgium wim leers Ghent ๐Ÿ‡ง๐Ÿ‡ช๐Ÿ‡ช๐Ÿ‡บ
  • @kunalsachdev opened merge request.
  • Status changed to Needs review about 1 year ago
  • ๐Ÿ‡บ๐Ÿ‡ธUnited States phenaproxima Massachusetts

    That looks pretty good to me. No remarks; as far as I'm concerned that's RTBC. I suspect the test failure is a random failure, but I don't have permission (seemingly) to re-run the failed job...

    So if you can re-run that job, and it passes, consider this me RTBCing.

  • ๐Ÿ‡ฎ๐Ÿ‡ณIndia kunal.sachdev

    The tests are passing now.

  • Status changed to Needs work about 1 year ago
  • ๐Ÿ‡ง๐Ÿ‡ชBelgium wim leers Ghent ๐Ÿ‡ง๐Ÿ‡ช๐Ÿ‡ช๐Ÿ‡บ

    The descriptions/labels of the config are very vague, but that's a pre-existing issue.

    Unfortunately that means that the validation constraints here turn out to be kinda nonsensical. Defining the minimum for user.flood:ip_window to be 1 is absurd:

       * @param int $window
       *   (optional) Number of seconds in the time window for this event (default is 3600
       *   seconds, or 1 hour).
    

    So we're saying that the minimum window is 1 second. Why does that make sense?

    The purpose of these config validation issues is not to blindly add validation constraints, but to first understand the configuration and how it is interpreted by the associated code/APIs, and then define sensible validation constraints.

  • Status changed to Needs review about 1 year ago
  • Status changed to Needs work about 1 year ago
  • ๐Ÿ‡ง๐Ÿ‡ชBelgium wim leers Ghent ๐Ÿ‡ง๐Ÿ‡ช๐Ÿ‡ช๐Ÿ‡บ

    Unfortunately that was a step in the wrong direction โ€ฆ so I explained how you can start moving this in the right direction: https://git.drupalcode.org/project/drupal/-/merge_requests/7469/diffs#no... ๐Ÿ˜Š

  • ๐Ÿ‡ณ๐Ÿ‡ฑNetherlands bbrala Netherlands

    Think your last comment does seem reasonable, guessing we could work with that.

  • ๐Ÿ‡ณ๐Ÿ‡ฑNetherlands bbrala Netherlands

    Handled all the comments and rebased. Think this is ok.

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

    I think this looks good, I don't think we need specific test coverage for these values.

    I wonder if we should ask for a user module maintainer for a review? Will ping kristiaan.

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

    I pinged kristiaan in slack, and in the meanwhile I figured there may be something else that we could do.
    Instead of doing a min check here, we just need to know that the value is > 0, because smaller is not an option.

    So I think isPositive might be a simpler way to validate this instead of being this specific.
    However, waiting to put this back to needs work based on feedback.

  • ๐Ÿ‡ง๐Ÿ‡ชBelgium kristiaanvandeneynde Antwerp, Belgium

    Gave some preliminary feedback on Slack, if it's not enough then we can quickly have a look in person in Leuven a week and a half from now. My only concern is that a too loose validation would allow config to contain values that the code does not handle well (or at all). So as long as that concern is taken care of, I'm fine with this.

Production build 0.71.5 2024