Create test that reports % of config entity types (and config schema types) that is validatable

Created on 2 December 2022, about 2 years ago
Updated 28 March 2024, 9 months ago

Problem/Motivation

While working on ✨ Add validation constraints to config_entity.dependencies Fixed and πŸ“Œ [PP-1] Convert field_storage_config and field_config's form validation logic to validation constraints Postponed , we observed that it's very difficult to get a sense of how much of a particular config schema tree (for example, filter.format.*, user.settings or field.storage.*.*), or subtree (for example, filter.format.*.dependencies) is covered by validation constraints.

Steps to reproduce

N/A

Proposed resolution

Add test that allows us to track which config schema subtrees are 100% validatable. This would enable us to avoid regressing until we finish 🌱 [META] Untie config validation from form validation β€” enables validatable Recipes, decoupled admin UIs … Active .

IOW: add this test coverage until 🌱 [META] Untie config validation from form validation β€” enables validatable Recipes, decoupled admin UIs … Active is done, and then we remove it again. It'd be both a progress tracker and a regression preventer.

Remaining tasks

User interface changes

None.

API changes

None.

Data model changes

None.

Release notes snippet

N/A

πŸ“Œ Task
Status

Fixed

Version

11.0 πŸ”₯

Component
ConfigurationΒ  β†’

Last updated 3 days ago

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.

  • The Needs Review Queue Bot β†’ tested this issue. It either no longer applies to Drupal core, or fails the Drupal core commit checks. Therefore, this issue status is now "Needs work".

    Apart from a re-roll or rebase, this issue may need more work to address feedback in the issue or MR comments. To progress an issue, incorporate this feedback as part of the process of updating the issue. This helps other contributors to know what is outstanding.

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

  • πŸ‡«πŸ‡·France andypost

    The use_more_text should be label but sometimes it saved as false because it should be translatable

    Thank to @chx https://drupal.slack.com/archives/C1BMUQ9U6/p1683905207064219

    sync/views.view.apps.yml:      use_more_text: 'See all >'
    sync/views.view.content_recent.yml:      use_more_text: More
    sync/views.view.release_notes.yml:      use_more_text: 'View All'
    sync/views.view.smartsheet_in_the_news.yml:        use_more_text: false
    sync/views.view.smartsheet_in_the_news.yml:      use_more_text: 'View All β€Ί'
    sync/views.view.smartsheet_in_the_news.yml:        use_more_text: false
    sync/views.view.smartsheet_in_the_news.yml:      use_more_text: 'Visit the newsroom β€Ί'
    sync/views.view.smartsheet_in_the_news.yml:        use_more_text: false
    sync/views.view.smartsheet_in_the_news.yml:      use_more_text: 'View All β€Ί'
    sync/views.view.taxonomy_term_content_hub_categories.yml:      use_more_text: 'View All β€Ί'
    sync/views.view.taxonomy_term_content_hub_categories.yml:        use_more_text: false
    sync/views.view.taxonomy_term_content_hub_categories.yml:      use_more_text: 'View All β€Ί'
    sync/views.view.tmgmt_job_overview.yml:        use_more_text: false
    sync/views.view.tmgmt_job_overview.yml:      use_more_text: 'See all jobs Β»'
    sync/views.view.tmgmt_job_overview.yml:        use_more_text: false
    sync/views.view.tmgmt_job_overview.yml:      use_more_text: 'See all jobs Β»'
    sync/views.view.user_admin_people.yml:      use_more_text: more
    
  • πŸ‡«πŸ‡·France andypost

    Filed child issue πŸ› Convert config schema to label for views use_more_text Closed: works as designed

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

    I think that based on what I did at πŸ“Œ Expose validation constraint violations in Config Inspector UI and drush command Fixed , I should be able to simplify things here 🀞

  • Assigned to wim leers
  • πŸ‡§πŸ‡ͺBelgium wim leers Ghent πŸ‡§πŸ‡ͺπŸ‡ͺπŸ‡Ί
  • πŸ‡§πŸ‡ͺBelgium borisson_ Mechelen, πŸ‡§πŸ‡ͺ

    @Wim Leers, can we mark this test as incomplete, so that we can allow this to run on d.o infrastructure and have output from it, without it having to sit in the queue?

    https://docs.phpunit.de/en/10.2/writing-tests-for-phpunit.html#incomplet...

  • Status changed to Needs review over 1 year ago
  • last update over 1 year ago
    Custom Commands Failed
  • πŸ‡§πŸ‡ͺBelgium wim leers Ghent πŸ‡§πŸ‡ͺπŸ‡ͺπŸ‡Ί

    Since #12, a handful of crucial issues have landed:

    1. type: machine_name: πŸ“Œ Add config validation for the allowed characters of machine names Fixed
    2. type: _core_config_info: πŸ“Œ Add validation constraints to _core_config_info Fixed
    3. type: langcode: ✨ Add a `langcode` data type to config schema Fixed

    The last 2 both in the past 2 weeks!

    These have made the following fully validatable:

    1. type: config_object
    2. comment.settings
    3. media_library.settings
    4. menu_ui.settings
    5. node.settings
    6. system.feature_flags

    Rerolled for all that, and compared to ~6 months ago in #3:

    πŸš€ Some real progress! 🀩

    #23: agreed, and looking into that πŸ‘

  • last update over 1 year ago
    29,869 pass, 2 fail
  • πŸ‡§πŸ‡ͺBelgium wim leers Ghent πŸ‡§πŸ‡ͺπŸ‡ͺπŸ‡Ί

    Self-review after ~6 months of absence and progress in Drupal core:

    +++ b/core/config/schema/core.data_types.schema.yml
    @@ -22,30 +22,45 @@ ignore:
     boolean:
       label: 'Boolean'
       class: '\Drupal\Core\TypedData\Plugin\DataType\BooleanData'
    +  constraints:
    +    PrimitiveType: []
    ...
     integer:
       label: 'Integer'
       class: '\Drupal\Core\TypedData\Plugin\DataType\IntegerData'
    +  constraints:
    +    PrimitiveType: [ ]
    

    This was done because:

    Fortunately, \Drupal\Core\TypedData\TypedDataManager::getDefaultConstraints() handles that for us. IMHO that should be moved into the config schema for explicitness, but that's subjective. πŸ€“

    β€” #6.1

    … but as we're trying to get this to a committable state, reverting it.

  • last update over 1 year ago
    29,880 pass, 1 fail
  • πŸ‡§πŸ‡ͺBelgium wim leers Ghent πŸ‡§πŸ‡ͺπŸ‡ͺπŸ‡Ί

    In addition to #25, I still stand by the rationale in #6.2 to do

    mapping:
        label: Mapping
        class: '\Drupal\Core\Config\Schema\Mapping'
        definition_class: '\Drupal\Core\TypedData\MapDataDefinition'
    +   constraints:
    +     # By default, only allow the explicitly listed mapping keys.
    +     ValidKeys: '<infer>'
    

    … but this is doing far more than just "create test". So let's remove that from the scope here and make this about only a test. Created πŸ“Œ `type: mapping` should use `ValidKeys: ` constraint by default Fixed for that.

  • last update over 1 year ago
    29,883 pass
  • πŸ‡§πŸ‡ͺBelgium wim leers Ghent πŸ‡§πŸ‡ͺπŸ‡ͺπŸ‡Ί

    Applying the trick that @borisson_ proposed. That indeed should make tests pass!

    If committed, this would:

    1. allow us to prevent further regressions: all new config schema types (and new config entity types) will cause this test to fail if they don't have validation constraints
    2. track progress of how many config schema types (and config entity types) are fully validatable: any time an additional one becomes validatable, this test will fail and would require an addition to \Drupal\KernelTests\Core\Config\ConfigSchemaValidatabilityTest::FINISHED_CONFIG_SCHEMA_SUBTREES

    To get the detailed output (as shown in e.g. #3), you'd have to run it locally and uncomment the two lines that contain this:

    $this->markTestIncomplete('Remove this when https://www.drupal.org/project/drupal/issues/2164373 is complete.');
    
  • Status changed to Needs work over 1 year ago
  • πŸ‡§πŸ‡ͺBelgium wim leers Ghent πŸ‡§πŸ‡ͺπŸ‡ͺπŸ‡Ί

    was added in #5 and is obsolete thanks to ✨ Add a `langcode` data type to config schema Fixed .

    Marking for:

    1. extracting one more piece from this issue into another
    2. making sure the logic is as simple as possible β€” my work on Config Inspector ~2 months ago suggests this can be simplified
  • πŸ‡§πŸ‡ͺBelgium borisson_ Mechelen, πŸ‡§πŸ‡ͺ
    1. +++ b/core/tests/Drupal/KernelTests/Core/Config/ConfigSchemaValidatabilityTest.php
      @@ -0,0 +1,668 @@
      +  /**
      +   * {@inheritdoc}
      +   *
      +   * Ironically, strict config schema checking must be disabled for this test to
      +   * run at all, because Drupal core does not have config schema for everything!
      

      Mixing inheritdoc and documentation is not allowed, so we need to copy over the rest of the documentation from the base implementation

    2. +++ b/core/tests/Drupal/KernelTests/Core/Config/ConfigSchemaValidatabilityTest.php
      @@ -0,0 +1,668 @@
      +  protected function getRawConfigSchemaDefinition(string $base_plugin_id): array {
      

      this needs docs

    3. +++ b/core/tests/Drupal/KernelTests/Core/Config/ConfigSchemaValidatabilityTest.php
      @@ -0,0 +1,668 @@
      +    // @todo support non-tail dynamic types.
      

      We need to file a followup or fix this in this issue as well.

      I'd prefer a followup because this is already very helpful as is.

    4. +++ b/core/tests/Drupal/KernelTests/Core/Config/ConfigSchemaValidatabilityTest.php
      @@ -0,0 +1,668 @@
      +    $this->assertCount(594, $incomplete, 'A new config schema type was added without validation constraints.');
      

      This can also be false when a complete schema is fixed; not sure if we need to change the message here.

      I don't think we should, so can be ignored.

    5. +++ b/core/tests/Drupal/KernelTests/Core/Config/ConfigSchemaValidatabilityTest.php
      @@ -0,0 +1,668 @@
      +   * (This is considered a single node in the tree.)
      

      brackets are not needed here I think.

    6. +++ b/core/tests/Drupal/KernelTests/Core/Config/ConfigSchemaValidatabilityTest.php
      @@ -0,0 +1,668 @@
      +  protected function isBaseType(string $type): bool {
      

      Needs docs

    7. +++ b/core/tests/Drupal/KernelTests/Core/Config/ConfigSchemaValidatabilityTest.php
      @@ -0,0 +1,668 @@
      +  protected static function getSubtree(array $definition): array {
      

      needs docs

    8. +++ b/core/tests/Drupal/KernelTests/Core/Config/ConfigSchemaValidatabilityTest.php
      @@ -0,0 +1,668 @@
      +  protected function getArrayElementProperties(array $definition): array {
      

      needs docs

    9. +++ b/core/tests/Drupal/KernelTests/Core/Config/ConfigSchemaValidatabilityTest.php
      @@ -0,0 +1,668 @@
      +  protected function computeSubtreeValidatability(array $subtree, string $parent_property_path) : ConfigSchemaValidatability {
      

      needs docs

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

    #31: thanks, indeed all those things I still need to address πŸ‘ #30.2 should actually address the majority of those 😊

    Meanwhile, πŸ“Œ `type: mapping` should use `ValidKeys: ` constraint by default Fixed landed, and led to another big boost! Or … it should have, but the numbers remain identical πŸ€” That must be a bug. I do remember working on πŸ“Œ Expose validation constraint violations in Config Inspector UI and drush command Fixed and starting from the code I wrote here, but realizing I could massively simplify it and make it more accurate. I'm hopeful that doing #30.2 will also fix that. 🀞

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

    Update after many more issues landed.

    Update since ~1 month ago in #24:

    πŸš€ Some real progress! 🀩

    Tackling #30 + #31 tomorrow.

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

    This is how the numbers in #33 were computed.

  • last update over 1 year ago
    30,058 pass
  • Status changed to Postponed about 1 year ago
  • πŸ‡§πŸ‡ͺBelgium wim leers Ghent πŸ‡§πŸ‡ͺπŸ‡ͺπŸ‡Ί

    This is an unsustainable core patch until such a time that it lands in core. It'll eventually be useful to do something like this … but only when we actually reach 100%, to avoid regressing.

    To be clear, we did make a ton of progress in the past few months:

    $ git pull
    Already up to date.
    $ vendor/bin/drush config:inspect | grep 100
      comment.settings                                       Correct   100%          βœ…βœ…  
      menu_ui.settings                                       Correct   100%          βœ…βœ…  
      node.settings                                          Correct   100%          βœ…βœ…  
      shortcut.set.default                                   Correct   100%          βœ…βœ…  
      system.feature_flags                                   Correct   100%          βœ…βœ…  
      system.maintenance                                     Correct   100%          βœ…βœ…  
      system.menu.account                                    Correct   100%          βœ…βœ…  
      system.menu.admin                                      Correct   100%          βœ…βœ…  
      system.menu.footer                                     Correct   100%          βœ…βœ…  
      system.menu.main                                       Correct   100%          βœ…βœ…  
      system.menu.tools                                      Correct   100%          βœ…βœ…  
      user.mail                                              Correct   100%          βœ…βœ…  
    $ vendor/bin/drush config:inspect | grep 100 | wc -l
          12
    

    Twelve fully validatable simple config objects right now!

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

    FYI: Over at πŸ“Œ Automated report on core config validatability Needs review , I'm working to generate a nice automated report, which eventually should also include charts πŸ€“

    The very first run is happening right now: https://git.drupalcode.org/project/config_inspector/-/jobs/147889 🀩

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

    On Dec 30, πŸ“Œ Automated report on core config validatability Needs review landed. It now generates an up-to-date visualization of core config validatability daily.

    It is currently underestimating because πŸ“Œ Configuration schema & required values: add test coverage for `nullable: true` validation support Fixed did not update the ones listed/surfaced by #35. Fixing that in πŸ“Œ Follow-up for #3364109: opt in already validatgable simple config to FullyValidatable Active .

  • Issue was unassigned.
  • Status changed to Fixed 9 months ago
  • πŸ‡§πŸ‡ͺBelgium wim leers Ghent πŸ‡§πŸ‡ͺπŸ‡ͺπŸ‡Ί

    Thanks to ✨ Add a "Validatable config" tests job to GitLab CI to help core evolve towards 100% validatability Fixed having landed, we don't need this anymore! πŸš€

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

Production build 0.71.5 2024