[META] Implement complete coverage of validatable config schema across plugins and entities

Created on 20 February 2025, 10 days ago

Problem/Motivation

Configuration schema and validatable constraints are incomplete or missing for configuration entities and plugin types, particularly Actions, Conditions, and Events. Without a complete schema, exported configurations lack proper validation, making it difficult to ensure data integrity across Drupal’s configuration system. This can lead to unexpected errors, inconsistencies in how configurations are stored and interpreted, and difficulty in debugging issues related to missing or incorrect configurations.

By implementing full coverage of configuration schema definitions, we can improve validation, enhance developer experience by providing clearer API expectations, and reduce the risk of invalid configurations being stored or exported. This will make configurations more predictable, enforceable, and resilient across different environments.

Steps to reproduce

The easiest way is to use the Configuration Inspector module to verify config schema is defined.

Proposed resolution

The best approach to solving this issue is to break the effort into multiple subtasks, each focusing on a specific plugin type or configuration entity. Since there are over 1000+ plugins that require schema coverage, a fully manual approach is less than ideal. Instead, we should aim to automate schema extraction where possible, leveraging tools and AI to analyze existing configurations and generate missing schema definitions.

Remaining tasks

TBD.

API changes

With the introduction of new configuration schema definitions, the way configurations are validated and exported will improve. While no breaking changes are expected, developers may notice that previously unvalidated configurations now require adjustments to conform to the enforced schema structures. Custom plugins and configurations should be tested against the updated validation rules to ensure compatibility.

Data model changes

The enhancements to configuration schema definitions will primarily impact how configurations are validated and structured in storage and export processes. There will be no fundamental changes to how data is stored, but configurations that previously contained unstructured or invalid data may now trigger validation errors. Developers should review and update any configurations that do not comply with the new schema definitions.

🌱 Plan
Status

Active

Version

2.0

Component

Code

Created by

🇺🇸United States michaellander

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

Comments & Activities

  • Issue created by @michaellander
  • 🇩🇪Germany jurgenhaas Gottmadingen

    Thank you @michaellander for cicking this of. I'm in full support of this idea and also added a related issue at 📌 Config validation for ECA models Active which was triggered by Wim Leers when he first saw ECA in action.

    In that related issue, @lammensj already got started with schema improvements for ECA config parts that are not yet down to the plugin level. Compared to the plugin level, that's probably the easier part, but still also very important.

    That leads me to the one big question mark that I can't get my head around to yet: when each plugin has its own schema being defined, that doesn't do much yet in terms of validation or improving the reliability. This is because the configuration for an individual plugin will never be stored as config at any time. The only exception would be if the action UI module were used where one could preconfigure actions for later use. But that is a very uncommon way and that module was just recently extracted from Drupal core and doesn't see much maintenance: action module .

    When ECA saves an ECA model in a config entity, that is constructed of the parts that are being worked on in the related issues followed by a list of plugins, each of which having a configuration property that contains a simple list of key-value pairs.

    If we wanted to cover that part in the ECA schema as well, we would have to have an aggregate of all the plugin schemas in the ECA schema. Or is there a way to refer to the plugin-specific schema by the plugin ID, including for all those unknown plugins that come from contrib modules?

  • 🇩🇪Germany jurgenhaas Gottmadingen
  • 🇺🇸United States michaellander

    If we wanted to cover that part in the ECA schema as well, we would have to have an aggregate of all the plugin schemas in the ECA schema. Or is there a way to refer to the plugin-specific schema by the plugin ID, including for all those unknown plugins that come from contrib modules?

    You only need to define schema for the actions you are defining, and then you are correct, you can just have an argument for the plugin_id to handle all actions, irregardless of if they are in your purview.
    Here are a few Action schema snippets from core:

    //from web/core/config/schema/core.entity.schema.yml
    action.configuration.action_send_email_action:
      type: mapping
      label: 'Send email configuration'
      mapping:
        recipient:
          type: string
          label: 'Recipient'
        subject:
          type: label
          label: 'Subject'
        message:
          type: text
          label: 'Message'
    

    and

    //from web/core/modules/user/config/schema/user.schema.yml
    action.configuration.user_add_role_action:
      type: mapping
      label: 'Configuration for the add role action'
      mapping:
        rid:
          type: string
          label: 'The ID of the role to add'
    

    Which would be covered by:

       type: action.configuration.[plugin_id]
    
Production build 0.71.5 2024