Expose validation constraints (and validatability %) in Config Inspector UI

Created on 27 May 2021, over 3 years ago
Updated 2 June 2023, over 1 year ago

Problem/Motivation

I'd love to see validation constraints show up in the Config Inspector UI β€” see 🌱 [META] Untie config validation from form validation β€” enables validatable Recipes, decoupled admin UIs … Active πŸ€“

In Drupal core, we only have:

# A UUID.
uuid:
  type: string
  label: 'UUID'
  constraints:
    Uuid: {}

… but hopefully more things will get that: 🌱 [meta] Add constraints to all simple configuration Active 🀞

So far only the CDN contrib module uses this extensively: #2969065: Use typed config validation constraints for validation of cdn.settings simple config β†’ .

Steps to reproduce

Proposed resolution

Remaining tasks

User interface changes

  1. β†’ #10
  2. β†’
  3. β†’ #27
  4. β†’ since #25: +

API changes

Data model changes

✨ Feature request
Status

Fixed

Version

2.1

Component

Code

Created by

πŸ‡§πŸ‡ͺBelgium wim leers Ghent πŸ‡§πŸ‡ͺπŸ‡ͺπŸ‡Ί

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

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

  • πŸ‡§πŸ‡ͺBelgium wim leers Ghent πŸ‡§πŸ‡ͺπŸ‡ͺπŸ‡Ί

    I've started building this! πŸ₯³

    I've got it working locally already. I'm building on top of πŸ“Œ Expose validation constraint violations in Config Inspector UI and drush command Fixed . I'm starting out with Validatability % first, but that means I've got 95% of what we need in place.

    Sneak preview:

  • πŸ‡§πŸ‡ͺBelgium wim leers Ghent πŸ‡§πŸ‡ͺπŸ‡ͺπŸ‡Ί

    While working on this, I've discovered two blocking core bugs, both of which I've added a work-around for:

    1. πŸ› TypedData instances created by TypedConfigManager::createFromNameAndData() are incomplete Fixed
    2. πŸ› Make 'sequence' Typed Data instances return type of 'sequence' instead of 'list' Fixed
  • Status changed to Needs review over 1 year ago
  • Open in Jenkins β†’ Open on Drupal.org β†’
    Core: 9.5.x + Environment: PHP 7.4 & MySQL 5.7
    last update over 1 year ago
    Patch Failed to Apply
  • πŸ‡§πŸ‡ͺBelgium wim leers Ghent πŸ‡§πŸ‡ͺπŸ‡ͺπŸ‡Ί

    1/4 done.

    1. $ vendor/bin/drush config:inspect --only-error
       --------------------- ---------- ------------- ---------- 
        Key                   Status     Validatable   Data      
       --------------------- ---------- ------------- ---------- 
        editor.editor.cke4    1 errors                           
        media.settings        Correct    17%           1 errors  
        system.theme.global   Correct    38%           1 errors  
        tour.tour.cdn-ui      8 errors                           
        update.settings       Correct    8%            1 errors  
       --------------------- ---------- ------------- ---------- 
      
    2. Nothing in core is 100% validatable, but when we start making more things validatable, this new flag will be really helpful:
      $ vendor/bin/drush config:inspect --only-error --invalidatability-is-error
       ----------------------------------------------------------- ---------- ------------- ---------- 
        Key                                                         Status     Validatable   Data      
       ----------------------------------------------------------- ---------- ------------- ---------- 
        automated_cron.settings                                     Correct    0%            Valid     
        automatic_updates.settings                                  Correct    20%           Valid     
        block.block.claro_breadcrumbs                               Correct    27%           Valid     
        block.block.claro_content                                   Correct    27%           Valid     
        block.block.claro_help                                      Correct    27%           Valid     
      …
        editor.editor.basic_html                                    Correct    69%           Valid     
      
      …
        system.menu.footer                                          Correct    40%           Valid     
        system.menu.main                                            Correct    40%           Valid     
        system.menu.tools                                           Correct    40%           Valid     
      …
        views.view.who_s_new                                        Correct    18%           Valid     
        views.view.who_s_online                                     Correct    17%           Valid     
       ----------------------------------------------------------- ---------- ------------- ---------- 
      
    3. Let's look at only a few:
      $ vendor/bin/drush config:inspect --only-error --invalidatability-is-error --filter-keys=media.settings,system.theme.global
       --------------------- --------- ------------- ---------- 
        Key                   Status    Validatable   Data      
       --------------------- --------- ------------- ---------- 
        media.settings        Correct   17%           1 errors  
        system.theme.global   Correct   38%           1 errors  
       --------------------- --------- ------------- ---------- 
      
    4. Let's add detail:
      $ vendor/bin/drush config:inspect --only-error --invalidatability-is-error --filter-keys=media.settings,system.theme.global --detail
       ------------------------------ --------- ------------- ----------------------------------------------------- 
        Key                            Status    Validatable   Data                                                 
       ------------------------------ --------- ------------- ----------------------------------------------------- 
        _core                          Correct   NOT                                                                
        _core.default_config_hash      Correct   NOT                                                                
        icon_base_uri                  Correct   NOT                                                                
        iframe_domain                  Correct   NOT                                                                
        oembed_providers_url           Correct   NOT                                                                
        media.settings:iframe_domain   Correct                 This value should be of the correct primitive type.  
        favicon                        Correct   NOT                                                                
        favicon.mimetype               Correct   NOT                                                                
        favicon.path                   Correct   NOT                                                                
        favicon.url                    Correct   NOT                                                                
        features                       Correct   NOT                                                                
        logo                           Correct   NOT                                                                
        logo.path                      Correct   NOT                                                                
        logo.url                       Correct   NOT                                                                
        system.theme.global:logo.url   Correct                 This value should be of the correct primitive type.  
       ------------------------------ --------- ------------- ----------------------------------------------------- 
      

    This looks surprisingly simple but took me MULTIPLE DAYS to put together! 😱

  • πŸ‡§πŸ‡ͺBelgium wim leers Ghent πŸ‡§πŸ‡ͺπŸ‡ͺπŸ‡Ί

    πŸ“Œ Expose validation constraint violations in Config Inspector UI and drush command Fixed landed! Now this patch will apply. Re-testing.

  • Open in Jenkins β†’ Open on Drupal.org β†’
    Core: 9.5.x + Environment: PHP 7.4 & MySQL 5.7
    last update over 1 year ago
    3 pass
  • πŸ‡­πŸ‡ΊHungary GΓ‘bor Hojtsy Hungary

    The code updates look good :) The only thing I am stuck on is whether "invalidatability" is a word or a good word at least? When I tried googling for it, Google suggested "invalidate ability" which means an entirely different thing. Should it be "--strict-validation" or only "--strict" even?

  • πŸ‡§πŸ‡ͺBelgium wim leers Ghent πŸ‡§πŸ‡ͺπŸ‡ͺπŸ‡Ί

    But "strict" already has a particular meaning in the config schema world: \Drupal\KernelTests\KernelTestBase::$strictConfigSchema:

      /**
       * Set to TRUE to strict check all configuration saved.
       *
       * @see \Drupal\Core\Config\Development\ConfigSchemaChecker
       *
       * @var bool
       */
      protected $strictConfigSchema = TRUE;
    

    IMHO "validatability" is just fine. Yes, it's kinda like "cacheability" in how little it was used. But it's perfectly valid English. And there is prior use of it beyond Drupal β€” for example \Symfony\Component\HttpFoundation\Response::isValidateable().

    How about --invalidatable-is-error or --not-validatable-is-error

  • Open in Jenkins β†’ Open on Drupal.org β†’
    Core: 9.5.x + Environment: PHP 7.4 & MySQL 5.7
    last update over 1 year ago
    2 pass, 2 fail
  • πŸ‡§πŸ‡ͺBelgium wim leers Ghent πŸ‡§πŸ‡ͺπŸ‡ͺπŸ‡Ί

    Now validatability is shown in the UI πŸ‘

    Next up: showing validation constraints.

  • The last submitted patch, 14: 3216089-14.patch, failed testing. View results β†’
    - codesniffer_fixes.patch Interdiff of automated coding standards fixes only.

  • Status changed to Needs work over 1 year ago
  • πŸ‡§πŸ‡ͺBelgium wim leers Ghent πŸ‡§πŸ‡ͺπŸ‡ͺπŸ‡Ί

    Thanks to #14 I noticed that media.settings has the type uri yet is marked as not validatable. That is not correct.

    The problem:
    interface UriInterface extends PrimitiveInterface β†’ note that this does not inherit StringInterface
    yet class Uri extends StringData implements UriInterface
    which means that due to class StringData extends PrimitiveBase implements StringInterface…
    Uri implements StringInterface too πŸ€ͺ

    I didn't account for that in ::computeNodeValidatability(). Fixed.

  • Status changed to Needs review over 1 year ago
  • Open in Jenkins β†’ Open on Drupal.org β†’
    Core: 9.5.x + Environment: PHP 7.4 & MySQL 5.7
    last update over 1 year ago
    PHPLint Failed
  • πŸ‡§πŸ‡ͺBelgium wim leers Ghent πŸ‡§πŸ‡ͺπŸ‡ͺπŸ‡Ί

    Oops, #14 and #16 were missing the new class that #10 added.

  • πŸ‡­πŸ‡ΊHungary GΓ‘bor Hojtsy Hungary

    I was thinking --error-if-invalid but that would be about the validation result not that it can be validated or not. Hm. --error-if-not-validateable could be an option but I'm still not 100% convinced :D It has a very particular spelling that may be easy to get wrong.

  • πŸ‡§πŸ‡ͺBelgium wim leers Ghent πŸ‡§πŸ‡ͺπŸ‡ͺπŸ‡Ί

    Maybe "strict" is fine. πŸ€” Because we'd eventually want \Drupal\KernelTests\KernelTestBase::$strictConfigSchema to actually validate things too.

    So … perhaps this is even appropriate! πŸ˜„

    I'll update the patch and open a core issue for doing exactly that.

  • Status changed to Needs work over 1 year ago
  • πŸ‡§πŸ‡ͺBelgium wim leers Ghent πŸ‡§πŸ‡ͺπŸ‡ͺπŸ‡Ί
    +++ b/src/Commands/InspectorCommands.php
    @@ -104,19 +128,36 @@ class InspectorCommands extends DrushCommands {
    +          if ($detail) {
    +            foreach ($raw_validatability->getValidatabilityPerPropertyPath() as $property_path => $is_validatable) {
    +              // Skip validatable property paths.
    +              if ($onlyError && $invalidatability_is_error && $is_validatable === TRUE) {
    +                continue;
    +              }
    +              $rows[$property_path] = ['key' => $property_path, 'status' => $status, 'validatability' => $is_validatable ? dt('Validatable') : dt('NOT'), 'data' => NULL];
    +            }
    +          }
    +          // Continue to validating the data: even with incomplete
    +          // validatability that is valuable to check.
    

    πŸ› This means that first "detail" rows are generated for each property path … and then we continue on toward validating, which results in output like this:

    $ vendor/bin/drush config:inspect --invalidatability-is-error --filter-keys=media.settings --detail
     ------------------------------------------ --------- ------------- ----------------------------------------------------- 
      Key                                        Status    Validatable   Data                                                 
     ------------------------------------------ --------- ------------- ----------------------------------------------------- 
      media.settings:_core                       Correct   NOT                                                                
      media.settings:_core.default_config_hash   Correct   NOT                                                                
      media.settings:icon_base_uri               Correct   NOT                                                                
      media.settings:iframe_domain               Correct   Validatable                                                        
      media.settings:oembed_providers_url        Correct   Validatable                                                        
      media.settings:standalone_url              Correct   NOT                                                                
      media.settings:_core                       Correct                 Valid                                                
      media.settings:_core.default_config_hash   Correct                 Valid                                                
      media.settings:icon_base_uri               Correct                 Valid                                                
      media.settings:iframe_domain               Correct                 This value should be of the correct primitive type.  
      media.settings:oembed_providers_url        Correct                 Valid                                                
      media.settings:standalone_url              Correct                 Valid                                                
     ------------------------------------------ --------- ------------- ----------------------------------------------------- 
    

    πŸ‘† Each property path is listed TWICE: once for "validatability" detail, once for "data validity" detail.

    That should of course be combined.

  • Status changed to Needs review over 1 year ago
  • Open in Jenkins β†’ Open on Drupal.org β†’
    Core: 9.5.x + Environment: PHP 7.4 & MySQL 5.7
    last update over 1 year ago
    3 pass
  • πŸ‡§πŸ‡ͺBelgium wim leers Ghent πŸ‡§πŸ‡ͺπŸ‡ͺπŸ‡Ί

    This is better:

    $ vendor/bin/drush config:inspect --invalidatability-is-error --filter-keys=media.settings --detail
     ------------------------------------------- --------- ------------- ----------------------------------------------------- 
      Key                                         Status    Validatable   Data                                                 
     ------------------------------------------- --------- ------------- ----------------------------------------------------- 
      media.settings                              Correct   33%           1 errors                                             
       media.settings:_core                       Correct   NOT           Valid                                                
       media.settings:_core.default_config_hash   Correct   NOT           Valid                                                
       media.settings:icon_base_uri               Correct   NOT           Valid                                                
       media.settings:iframe_domain               Correct   Validatable   This value should be of the correct primitive type.  
       media.settings:oembed_providers_url        Correct   Validatable   Valid                                                
       media.settings:standalone_url              Correct   NOT           Valid                                                
     ------------------------------------------- --------- ------------- ----------------------------------------------------- 
    

    I took the liberty of slightly changing how --detail works. Rather than showing only details, I'm now also keeping the row for the containing config. Because that gives you a valuable high-level perspective: the % of validatability and the number of errors. Given the increase in information provided, I think this is a reasonable change.

    Also fixed the PHPLint error (which does not occur on PHP 8, hence I missed it).

  • Open in Jenkins β†’ Open on Drupal.org β†’
    Core: 9.5.x + Environment: PHP 7.4 & MySQL 5.7
    last update over 1 year ago
    3 pass
  • πŸ‡§πŸ‡ͺBelgium wim leers Ghent πŸ‡§πŸ‡ͺπŸ‡ͺπŸ‡Ί

    I changed it to use --strict but ran into

    $ vendor/bin/drush config:inspect --strict --filter-keys=media.settings --detail
    PHP Fatal error:  Uncaught TypeError: Drush\Preflight\PreflightArgs::setStrict(): Argument #1 ($strict) must be of type bool, null given in /Users/wim.leers/core/vendor/drush/drush/src/Preflight/PreflightArgs.php:453
    Stack trace:
    #0 [internal function]: Drush\Preflight\PreflightArgs->setStrict(NULL)
    #1 /Users/wim.leers/core/vendor/drush/drush/src/Preflight/ArgsPreprocessor.php(85): call_user_func(Array, NULL)
    

    … turns out drush reserves this argument: \Drush\Preflight\PreflightArgs::isStrict() πŸ€·β€β™€οΈ

    So --strict-validation it is!

  • Open in Jenkins β†’ Open on Drupal.org β†’
    Core: 9.5.x + Environment: PHP 7.4 & MySQL 5.7
    last update over 1 year ago
    3 pass
  • πŸ‡§πŸ‡ͺBelgium wim leers Ghent πŸ‡§πŸ‡ͺπŸ‡ͺπŸ‡Ί

    Fixed a typo from #22 … and refactored the logic to support collecting all validation constraints.

    This actually allowed me to delete code! πŸ˜…πŸ₯³ (Turns out I was computing certain things twice…)

    No UI yet: not in Drush nor in the web UI.

  • Open in Jenkins β†’ Open on Drupal.org β†’
    Core: 9.5.x + Environment: PHP 7.4 & MySQL 5.7
    last update over 1 year ago
    3 pass
  • πŸ‡§πŸ‡ͺBelgium wim leers Ghent πŸ‡§πŸ‡ͺπŸ‡ͺπŸ‡Ί

    Noticed a bug introduced in #16 while verifying that the output for #23 still matched that of earlier patch iterations (it did β€” until #16 as expected, which is how I spotted this bug) β€” I inverted the condition there but forgot about one of the documented edge cases: BooleanInterface. Correctly handling that again results in significantly higher percentage of validatability, because a lot of config schemas use type: boolean.

  • Open in Jenkins β†’ Open on Drupal.org β†’
    Core: 9.5.x + Environment: PHP 7.4 & MySQL 5.7
    last update over 1 year ago
    3 pass
  • πŸ‡§πŸ‡ͺBelgium wim leers Ghent πŸ‡§πŸ‡ͺπŸ‡ͺπŸ‡Ί

    I do not yet see how the list of validation constraints can sanely be shown on the Overview or the List view. But I can see a way for the Tree view:

    (Also fixed a missing use from #24 β€” splitting up in atomic commits allows for easy mistakes πŸ™ˆ)

  • πŸ‡§πŸ‡ͺBelgium wim leers Ghent πŸ‡§πŸ‡ͺπŸ‡ͺπŸ‡Ί

    … but I really believe that such a bulleted list just does not give enough context. I think symbols can provide a lot of clarity here, without the need for adding a lot of additional words:

    P.S.: I went all the way, and made this work well in RTL contexts too:

  • Issue was unassigned.
  • Open in Jenkins β†’ Open on Drupal.org β†’
    Core: 9.5.x + Environment: PHP 7.4 & MySQL 5.7
    last update over 1 year ago
    3 pass
  • πŸ‡§πŸ‡ͺBelgium wim leers Ghent πŸ‡§πŸ‡ͺπŸ‡ͺπŸ‡Ί

    And now, the ability to list constraints using --list-constraints in Drush:

    1. Let's look at my module's config:
      $ vendor/bin/drush config:inspect --filter-keys=cdn.settings
       -------------- --------- ------------- ------- 
        Key            Status    Validatable   Data   
       -------------- --------- ------------- ------- 
        cdn.settings   Correct   36%           Valid  
       -------------- --------- ------------- ------- 
      
    2. Let's add detail:
      $ vendor/bin/drush config:inspect --filter-keys=cdn.settings --detail
       ----------------------------------------- --------- ------------- ------- 
        Key                                       Status    Validatable   Data   
       ----------------------------------------- --------- ------------- ------- 
        cdn.settings                              Correct   36%           Valid  
         cdn.settings:                            Correct   NOT           Valid  
         cdn.settings:_core                       Correct   NOT           Valid  
         cdn.settings:_core.default_config_hash   Correct   NOT           Valid  
         cdn.settings:farfuture                   Correct   NOT           Valid  
         cdn.settings:farfuture.status            Correct   Validatable   Valid  
         cdn.settings:langcode                    Correct   NOT           Valid  
         cdn.settings:mapping                     Correct   NOT           Valid  
         cdn.settings:mapping.conditions          Correct   NOT           Valid  
         cdn.settings:mapping.domain              Correct   Validatable   Valid  
         cdn.settings:mapping.type                Correct   NOT           Valid  
         cdn.settings:scheme                      Correct   Validatable   Valid  
         cdn.settings:status                      Correct   Validatable   Valid  
         cdn.settings:stream_wrappers             Correct   NOT           Valid  
         cdn.settings:stream_wrappers.0           Correct   Validatable   Valid  
       ----------------------------------------- --------- ------------- ------- 
      
    3. Let's list the constraints too:
      $ vendor/bin/drush config:inspect --filter-keys=cdn.settings --detail --list-constraints
       ----------------------------------------- --------- ------------- ------- ----------------------------------------------------------------------------- 
        Key                                       Status    Validatable   Data    Validation constraints                                                       
       ----------------------------------------- --------- ------------- ------- ----------------------------------------------------------------------------- 
        cdn.settings                              Correct   36%           Valid                                                                                
         cdn.settings:                            Correct   NOT           Valid                                                                                
         cdn.settings:_core                       Correct   NOT           Valid                                                                                
         cdn.settings:_core.default_config_hash   Correct   NOT           Valid                                                                                
         cdn.settings:farfuture                   Correct   NOT           Valid                                                                                
         cdn.settings:farfuture.status            Correct   Validatable   Valid   Drupal\Core\Validation\Plugin\Validation\Constraint\PrimitiveTypeConstraint  
         cdn.settings:langcode                    Correct   NOT           Valid                                                                                
         cdn.settings:mapping                     Correct   NOT           Valid                                                                                
         cdn.settings:mapping.conditions          Correct   NOT           Valid                                                                                
         cdn.settings:mapping.domain              Correct   Validatable   Valid   Drupal\cdn\Plugin\Validation\Constraint\CdnDomainConstraint                  
                                                                                  Drupal\Core\Validation\Plugin\Validation\Constraint\PrimitiveTypeConstraint  
         cdn.settings:mapping.type                Correct   NOT           Valid                                                                                
         cdn.settings:scheme                      Correct   Validatable   Valid   Drupal\cdn\Plugin\Validation\Constraint\CdnSchemeConstraint                  
                                                                                  Drupal\Core\Validation\Plugin\Validation\Constraint\PrimitiveTypeConstraint  
         cdn.settings:status                      Correct   Validatable   Valid   Drupal\Core\Validation\Plugin\Validation\Constraint\PrimitiveTypeConstraint  
         cdn.settings:stream_wrappers             Correct   NOT           Valid                                                                                
         cdn.settings:stream_wrappers.0           Correct   Validatable   Valid   Drupal\cdn\Plugin\Validation\Constraint\CdnStreamWrapperConstraint           
                                                                                  Drupal\Core\Validation\Plugin\Validation\Constraint\PrimitiveTypeConstraint  
       ----------------------------------------- --------- ------------- ------- ----------------------------------------------------------------------------- 
      
    4. Great, now let's limit it to errors only:
      $ vendor/bin/drush config:inspect --filter-keys=cdn.settings --detail --list-constraints --only-error
       ----- -------- ------------- ------ ------------------------ 
        Key   Status   Validatable   Data   Validation constraints  
       ----- -------- ------------- ------ ------------------------ 
      
    5. That listed nothing because the config schema is valid and all data is valid. So now let's enable the strict validation mode:
      $ vendor/bin/drush config:inspect --filter-keys=cdn.settings --detail --list-constraints --only-error --strict-validation
       ----------------------------------------- --------- ------------- ------- ------------------------ 
        Key                                       Status    Validatable   Data    Validation constraints  
       ----------------------------------------- --------- ------------- ------- ------------------------ 
        cdn.settings                              Correct   36%           Valid                           
         cdn.settings:                            Correct   NOT           Valid                           
         cdn.settings:_core                       Correct   NOT           Valid                           
         cdn.settings:_core.default_config_hash   Correct   NOT           Valid                           
         cdn.settings:farfuture                   Correct   NOT           Valid                           
         cdn.settings:langcode                    Correct   NOT           Valid                           
         cdn.settings:mapping                     Correct   NOT           Valid                           
         cdn.settings:mapping.conditions          Correct   NOT           Valid                           
         cdn.settings:mapping.type                Correct   NOT           Valid                           
         cdn.settings:stream_wrappers             Correct   NOT           Valid                           
       ----------------------------------------- --------- ------------- ------- ------------------------ 
      

    I think/hope this proves that this all works great now. Let's switch to the example I used for showing the validatability before: media.settings:

    $ vendor/bin/drush config:inspect --filter-keys=media.settings --detail --list-constraints --only-error --strict-validation
     ------------------------------------------- --------- ------------- ----------------------------------------------------- -------------------------------------------------------- 
      Key                                         Status    Validatable   Data                                                  Validation constraints                                  
     ------------------------------------------- --------- ------------- ----------------------------------------------------- -------------------------------------------------------- 
      media.settings                              Correct   43%           1 errors                                                                                                      
       media.settings:                            Correct   NOT           Valid                                                                                                         
       media.settings:_core                       Correct   NOT           Valid                                                                                                         
       media.settings:_core.default_config_hash   Correct   NOT           Valid                                                                                                         
       media.settings:icon_base_uri               Correct   NOT           Valid                                                                                                         
       media.settings:iframe_domain               Correct   Validatable   This value should be of the correct primitive type.   Drupal\Core\Validation\Plugin\Validation\Constraint\Pr  
                                                                                                                                imitiveTypeConstraint                                   
     ------------------------------------------- --------- ------------- ----------------------------------------------------- -------------------------------------------------------- 
    

    That's the same command as the one above, just replacing cdn.settings with media.settings. Makes sense to me!

    IMHO this is ready now. An idea for a follow-up could be to distinguish between inherited constraints vs local constraints β€” that would make it clear that for example the _core key (which is present in both cdn.settings and media.settings's Drush output) actually is of the type _core_config_info β€” so adding a validation constraint there would fix it everywhere.

  • πŸ‡§πŸ‡ͺBelgium wim leers Ghent πŸ‡§πŸ‡ͺπŸ‡ͺπŸ‡Ί

    Another follow-up would be to map the FQCNs to the equivalent types:

    • \Drupal\Core\Validation\Plugin\Validation\Constraint\PrimitiveTypeConstraint would become PrimitiveType because of
       * @Constraint(
       *   id = "PrimitiveType",
       *   label = @Translation("Primitive type", context = "Validation")
       * )
      
    • \Drupal\cdn\Plugin\Validation\Constraint\CdnDomainConstraint would become CdnDomain because of
       * @Constraint(
       *   id = "CdnDomain",
       *   label = @Translation("CDN domain", context = "Validation"),
       * )
      
    • and so on
    • … but that's really just a nice-to-have compared to today, where this information is still painfully difficult to access.

  • πŸ‡§πŸ‡ͺBelgium wim leers Ghent πŸ‡§πŸ‡ͺπŸ‡ͺπŸ‡Ί
  • πŸ‡§πŸ‡ͺBelgium wim leers Ghent πŸ‡§πŸ‡ͺπŸ‡ͺπŸ‡Ί
  • Status changed to Needs work over 1 year ago
  • πŸ‡­πŸ‡ΊHungary GΓ‘bor Hojtsy Hungary

    Looks great overall! I think there is a disconnect where we say the data is not validatable and then we say the data is valid :) Can we unbreak the terminology mismatch there?

  • Status changed to Needs review over 1 year ago
  • Open in Jenkins β†’ Open on Drupal.org β†’
    Core: 9.5.x + Environment: PHP 7.4 & MySQL 5.7
    last update over 1 year ago
    3 pass
  • πŸ‡§πŸ‡ͺBelgium wim leers Ghent πŸ‡§πŸ‡ͺπŸ‡ͺπŸ‡Ί

    Good call!

    I was not happy about that either.

    Having worked on πŸ“Œ KernelTestBase::$strictConfigSchema = TRUE and BrowserTestBase::$strictConfigSchema = TRUE do not actually strictly validate Fixed in the mean time, I think I know how to distinguish: Valid (when actually properly validatable) vs Correct primitive type (when no real validation constraints are present, only primitive type is being checked):

    $ vendor/bin/drush config:inspect --filter-keys=system.theme.global --detail --strict-validation
     --------------------------------------------------------- --------- ------------- ----------------------------------------------------- 
      Key                                                       Status    Validatable   Data                                                 
     --------------------------------------------------------- --------- ------------- ----------------------------------------------------- 
      system.theme.global                                       Correct   53%           1 errors                                             
       system.theme.global:                                     Correct   NOT           Correct primitive type                               
       system.theme.global:_core                                Correct   Validatable   Valid                                                
       system.theme.global:_core.default_config_hash            Correct   Validatable   Valid                                                
       system.theme.global:favicon                              Correct   NOT           Correct primitive type                               
       system.theme.global:favicon.mimetype                     Correct   NOT           Correct primitive type                               
       system.theme.global:favicon.path                         Correct   NOT           Correct primitive type                               
       system.theme.global:favicon.url                          Correct   NOT           Correct primitive type                               
       system.theme.global:favicon.use_default                  Correct   Validatable   Valid                                                
       system.theme.global:features                             Correct   NOT           Correct primitive type                               
       system.theme.global:features.comment_user_picture        Correct   Validatable   Valid                                                
       system.theme.global:features.comment_user_verification   Correct   Validatable   Valid                                                
       system.theme.global:features.favicon                     Correct   Validatable   Valid                                                
       system.theme.global:features.node_user_picture           Correct   Validatable   Valid                                                
       system.theme.global:logo                                 Correct   NOT           Correct primitive type                               
       system.theme.global:logo.path                            Correct   NOT           Correct primitive type                               
       system.theme.global:logo.url                             Correct   Validatable   This value should be of the correct primitive type.  
       system.theme.global:logo.use_default                     Correct   Validatable   Valid                                                
     --------------------------------------------------------- --------- ------------- ----------------------------------------------------- 
    

    and in the UI:

    What do you think?

  • πŸ‡«πŸ‡·France andypost

    Thank you Wim! It's very helpful and require to fix previous commit...

    But when I'm looking at report in browser/drush the amount of duplicated Correct primitive type makes my eyes skip errors because errors are shorter and less visible (skimmable)

    As this value is displayed for every non-error line it could be added to "legend" (above or below table) to prevent printing expected defaults on each line.

    On fresh core install 10.1.x it shows only 2 errors and no performance affected

    $ time drush config:inspect --only-error  --list-constraints --detail
     ------------------------------- --------- ------------- ----------------------------------------------------- ------------------------------------------------------------- 
      Key                             Status    Validatable   Data                                                  Validation constraints                                       
     ------------------------------- --------- ------------- ----------------------------------------------------- ------------------------------------------------------------- 
      system.theme.global             Correct   41%           1 errors                                                                                                           
       system.theme.global:logo.url   Correct   Validatable   This value should be of the correct primitive type.   Drupal\Core\Validation\Plugin\Validation\Constraint\Primiti  
                                                                                                                    veTypeConstraint                                             
      update.settings                 Correct   14%           1 errors                                                                                                           
       update.settings:fetch.url      Correct   Validatable   This value should be of the correct primitive type.   Drupal\Core\Validation\Plugin\Validation\Constraint\Primiti  
                                                                                                                    veTypeConstraint                                             
     ------------------------------- --------- ------------- ----------------------------------------------------- ------------------------------------------------------------- 
    real	0m 2.66s
    user	0m 2.40s
    sys	0m 0.23s
    

    btw I can't install module for 11.x branch)

    +++ b/src/Commands/InspectorCommands.php
    @@ -104,43 +138,113 @@ class InspectorCommands extends DrushCommands {
    +          $validatability = dt('@validatability%', ['@validatability' => intval($raw_validatability->computePercentage() * 100)]);
    ...
           $rows[$name] = ['key' => $name, 'status' => $status, 'validatability' => $validatability, 'data' => $data];
    

    Moreover without this patch the variable is undefined in current 2.1.x branch

  • Status changed to Needs work over 1 year ago
  • πŸ‡­πŸ‡ΊHungary GΓ‘bor Hojtsy Hungary

    I agree with @andypost that a shorter result would be better with a legend if needed, especially in the drush result.

  • Status changed to Needs review over 1 year ago
  • Open in Jenkins β†’ Open on Drupal.org β†’
    Core: 9.5.x + Environment: PHP 7.4 & MySQL 5.7
    last update over 1 year ago
    3 pass
  • πŸ‡§πŸ‡ͺBelgium wim leers Ghent πŸ‡§πŸ‡ͺπŸ‡ͺπŸ‡Ί

    Adding a legend is trivial per https://symfony.com/doc/current/components/console/helpers/table.html#sp.... We could choose to add it at the top or bottom.

    But … \Consolidation\OutputFormatters\FormatterManager::write()'s unavoidable call to \Consolidation\OutputFormatters\FormatterManager::validateAndRestructure() unfortunately forcefully requires every row to contain the columns that all other rows have.

    After a LOT of searching and trial and error I found a way to make it work. But this only allows us putting the legend at the top. (Which is probably preferable anyway.) This is the result:

    $ vendor/bin/drush config:inspect --filter-keys=media.settings --strict-validation --detail
     Legend for Data: 
      βœ…β“  β†’ Correct primitive type, detailed validation impossible.
      βœ…βœ…  β†’ Correct primitive type, passed all validation constraints.
     -------------------------------- --------- ------------- ------------------------------------- 
      Key                              Status    Validatable   Data                                 
     -------------------------------- --------- ------------- ------------------------------------- 
      media.settings                   Correct   43%           1 errors                             
       media.settings:                 Correct   NOT           βœ…β“                                 
       media.settings:_core            Correct   NOT           βœ…β“                                 
       media.settings:_core.default_   Correct   NOT           βœ…β“                                 
      config_hash                                                                                   
       media.settings:icon_base_uri    Correct   NOT           βœ…β“                                 
       media.settings:iframe_domain    Correct   Validatable   This value should be of the correct  
                                                               primitive type.                      
       media.settings:oembed_provide   Correct   Validatable   βœ…βœ…                                 
      rs_url                                                                                        
       media.settings:standalone_url   Correct   Validatable   βœ…βœ…                                 
     -------------------------------- --------- ------------- ------------------------------------- 
    

    Note that the legend only appears when needed:

    $ vendor/bin/drush config:inspect --filter-keys=media.settings --strict-validation
     ---------------- --------- ------------- ---------- 
      Key              Status    Validatable   Data      
     ---------------- --------- ------------- ---------- 
      media.settings   Correct   43%           1 errors  
     ---------------- --------- ------------- ---------- 
    

    and

    $ vendor/bin/drush config:inspect --filter-keys=media.settings --strict-validation --detail --fields=key,status,validatability
     ------------------------------------------- --------- ------------- 
      Key                                         Status    Validatable  
     ------------------------------------------- --------- ------------- 
      media.settings                              Correct   43%          
       media.settings:                            Correct   NOT          
       media.settings:_core                       Correct   NOT          
       media.settings:_core.default_config_hash   Correct   NOT          
       media.settings:icon_base_uri               Correct   NOT          
       media.settings:iframe_domain               Correct   Validatable  
       media.settings:oembed_providers_url        Correct   Validatable  
       media.settings:standalone_url              Correct   Validatable  
     ------------------------------------------- --------- ------------- 
    

    I also made it stand out visually:

    Finally, I made this work in the UI too:

  • Status changed to RTBC over 1 year ago
  • πŸ‡«πŸ‡·France andypost

    It looks great!

  • πŸ‡«πŸ‡·France andypost

    It looks good even on light terminal

  • Open in Jenkins β†’ Open on Drupal.org β†’
    Core: 9.5.x + Environment: PHP 7.4 & MySQL 5.7
    last update over 1 year ago
    3 pass
  • πŸ‡­πŸ‡ΊHungary GΓ‘bor Hojtsy Hungary

    Rerolled following πŸ“Œ Config inspection should wipe relevant caches to always get up-to-date results Fixed . Let's make sure it passes our smoke tests.

    • 89100229 committed on 2.1.x
      Issue #3216089 by Wim Leers, GΓ‘bor Hojtsy, andypost, vuil: Expose...
  • Status changed to Fixed over 1 year ago
  • πŸ‡­πŸ‡ΊHungary GΓ‘bor Hojtsy Hungary

    Yay, committed! We can refine this forward as needed.

  • πŸ‡§πŸ‡ͺBelgium wim leers Ghent πŸ‡§πŸ‡ͺπŸ‡ͺπŸ‡Ί

    AWESOME! 😊πŸ₯³πŸ™

    I already started working on what I said in #27 and #28:

    An idea for a follow-up could be to distinguish between inherited constraints vs local constraints β€” that would make it clear that for example the _core key (which is present in both cdn.settings and media.settings's Drush output) actually is of the type _core_config_info β€” so adding a validation constraint there would fix it everywhere.

    +

    Another follow-up would be to map the FQCNs to the equivalent types:

    • \Drupal\Core\Validation\Plugin\Validation\Constraint\PrimitiveTypeConstraint would become PrimitiveType because of
       * @Constraint(
       *   id = "PrimitiveType",
       *   label = @Translation("Primitive type", context = "Validation")
       * )
      
    • \Drupal\cdn\Plugin\Validation\Constraint\CdnDomainConstraint would become CdnDomain because of
       * @Constraint(
       *   id = "CdnDomain",
       *   label = @Translation("CDN domain", context = "Validation"),
       * )
      
    • and so on
    • … but that's really just a nice-to-have compared to today, where this information is still painfully difficult to access.

    Stay tuned!

  • πŸ‡§πŸ‡ͺBelgium kristiaanvandeneynde Antwerp, Belgium

    Ooh, shiny. Nice work!

  • πŸ‡³πŸ‡±Netherlands ronaldtebrake

    Awesome work, looking forward to using this!

  • πŸ‡§πŸ‡ͺBelgium wim leers Ghent πŸ‡§πŸ‡ͺπŸ‡ͺπŸ‡Ί
  • πŸ‡§πŸ‡ͺBelgium wim leers Ghent πŸ‡§πŸ‡ͺπŸ‡ͺπŸ‡Ί
  • Automatically closed - issue fixed for 2 weeks with no activity.

Production build 0.71.5 2024