Problem/Motivation

When using a Views block (e.g., Blog listing) with Drupal's FullyValidatable constraint on the views_block config schema, saving or publishing the block configuration produces 5 validation
errors:

  • 'pager' is a required key.
  • 'fields' is a required key.
  • 'filter' is a required key.
  • 'sort' is a required key.
  • 'pager_offset' is a required key.

This happens because ctools_views_config_schema_info_alter() adds these keys to the views_block schema mapping without setting requiredKey: false. Since the base
views_block schema type (defined in core/modules/views/config/schema/views.schema.yml) has the FullyValidatable constraint, all mapping keys without requiredKey: false are
treated as required.

Drupal core's own optional keys in the same schema (views_label, items_per_page) already use requiredKey: false because they are only present when the corresponding "Allow settings"
options are enabled on the Views block display.

The keys added by ctools_views are equally optional — they are only populated when their respective allow settings (pager, offset, hide_fields, sort_fields,
disable_filters, configure_sorts) are enabled. Without requiredKey: false, config validation fails for any Views block that doesn't have all of these settings enabled.

This is reproducible with any module that validates Views block config entities (e.g., Canvas, Layout Builder).

Steps to reproduce

  1. Install a Drupal CMS 2.0 site with ctools (4.1.0) and any module that triggers config validation on Views blocks with Drupal Canvas.
  2. Place a Views block (e.g., a Blog listing) on a Canvas page.
  3. Attempt to save/publish the page.
  4. Observe the 5 validation errors about required keys.

Proposed resolution

Add 'requiredKey' => FALSE to all 6 keys that ctools_views_config_schema_info_alter() adds to the views_block mapping: pager, fields,
filter, exposed, sort, and pager_offset.

This aligns with how Drupal CMS, Drupal Canvas on top of Drupal Core which handles its own optional keys in the same schema.

Remaining tasks

User interface changes

API changes

Data model changes

Issue fork ctools-3572317

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

rajab natshah created an issue. See original summary.

rajab natshah’s picture

Status: Active » Needs review

joelpittet made their first commit to this issue’s fork.

joelpittet’s picture

Status: Needs review » Fixed

Thanks @rajab natshah

Now that this issue is closed, review the contribution record.

As a contributor, attribute any organization that helped you, or if you volunteered your own time.

Maintainers, credit people who helped resolve this issue.

Status: Fixed » Closed (fixed)

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