ValidKeysConstraintValidator thrown by Config Inspector on Drupal 10.1.x and 10.2.x due to core bug triggered only by Config Inspector

Created on 19 January 2024, 11 months ago
Updated 18 April 2024, 8 months ago

Respect the submission guidelines above! Drupal.org issue forks cause additional work for the project maintainer!

Setup

  • Solr version: n/a
  • Drupal Core version: 10.2
  • Search API version:n/a
  • Search API Solr version: 4.3.2
  • Configured Solr Connector: n/a

Issue

Install this module
Install config inspector
View the report at: /admin/reports/config-inspector
Error thrown on search_api_solr.solr_cache.*:solr_configs because it is null and the validator is expecting an empty array.

💬 Support request
Status

Fixed

Version

4.0

Component

Code

Created by

heddn Nicaragua

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

Comments & Activities

  • Issue created by @heddn
  • heddn Nicaragua

    I think is comes from all of the nullable: true stuff all over the config schema in this module. There is a lot of it though, so I wonder if something in core should be handling this differently.

  • Status changed to Postponed: needs info 11 months ago
  • 🇧🇪Belgium wim leers Ghent 🇧🇪🇪🇺

    Does this happen only when using https://www.drupal.org/project/config_inspector 's UI?

  • Status changed to Active 11 months ago
  • heddn Nicaragua

    Automated testing in the CI where we essentially do protected $strictConfigSchema = TRUE does not trigger any exceptions. Running drush config:inspect --only-error and the web UI trigger the same exception logic.

  • Status changed to Postponed: needs info 11 months ago
  • 🇧🇪Belgium wim leers Ghent 🇧🇪🇪🇺

    Thanks for the fast response! 👍

    Automated testing in the CI where we essentially do protected $strictConfigSchema = TRUE does not trigger any exceptions.

    Excellent, that means no production sites are impacted 👍

    Running drush config:inspect --only-error and the web UI trigger the same exception logic.

    That's because I changed \Drupal\config_inspector\ConfigInspectorManager::validateValues() (I'm a co-maintainer of Config Inspector now) in 📌 Expose validation constraint violations in Config Inspector UI and drush command Fixed to execute validation constraints.

    You should be able to reproduce this ever since #3092298: Solr Caches should be managed via Drupal's config management happened, with the most recent version of Config Inspector, on all versions of Drupal core.

    Could you please try this on Drupal 10.1 or 10.0? 🙏 That'd confirm my hypothesis 😊

  • Status changed to Active 11 months ago
  • heddn Nicaragua

    What version of config inspector? The most recent? None of my sites are still using 10.0/10.1 any more but when were still using it, we didn't have issues. It was only recently this started.

  • 🇧🇪Belgium wim leers Ghent 🇧🇪🇪🇺

    What is the exact validation error message, by which validation constraint does it get generated?

  • heddn Nicaragua

    Line 22-24 is what is triggered. Solr has those values as null. But the validator thinks they should be an empty array.

        if (!is_array($value)) {
          throw new UnexpectedTypeException($value, 'array');
        }
    
  • 🇬🇧United Kingdom 2dareis2do

    Thanks @heddin. I am having similar issue with custom migrate script using custom module with migrate_tools dependency and migration lookup config?

    https://www.drupal.org/project/config_inspector/issues/3416934 🐛 Config inspector stopped working after Drupal 10.2 update Active

  • 🇬🇧United Kingdom 2dareis2do

    Is there a core issue for this?

  • 🇬🇧United Kingdom 2dareis2do

    I was able to add the following to circumvent fatal error on migrate lookup config

    migration_dependencies:
      required: {  }
      optional: {  }
  • 🇬🇧United Kingdom 2dareis2do

    This is the error I am seeing:

    Symfony\Component\Validator\Exception\UnexpectedTypeException: Expected argument of type "array", "null" given in Drupal\Core\Validation\Plugin\Validation\Constraint\ValidKeysConstraintValidator->validate() (line 23 of core/lib/Drupal/Core/Validation/Plugin/Validation/Constraint/ValidKeysConstraintValidator.php).
    Drupal\Core\TypedData\Validation\RecursiveContextualValidator->validateConstraints(NULL, '00000000000014f10000000000000000', Array) (Line: 154)
    Drupal\Core\TypedData\Validation\RecursiveContextualValidator->validateNode(Object) (Line: 164)
    Drupal\Core\TypedData\Validation\RecursiveContextualValidator->validateNode(Object, Array, 1) (Line: 106)
    Drupal\Core\TypedData\Validation\RecursiveContextualValidator->validate(Object, NULL, NULL) (Line: 93)
    Drupal\Core\TypedData\Validation\RecursiveValidator->validate(Object) (Line: 132)
    Drupal\Core\TypedData\TypedData->validate() (Line: 352)
    Drupal\config_inspector\ConfigInspectorManager->validateValues('search_api_solr.solr_cache.cache_document_default_7_0_0') (Line: 176)
    Drupal\config_inspector\Controller\ConfigInspectorController->overview()
    call_user_func_array(Array, Array) (Line: 123)
  • 🇬🇧United Kingdom 2dareis2do

    From /admin/config/search/search-api/server/streathamlife/solr_cache

    We have the following (see attached)

    namely

    @label	Minimum Solr Version	Environment	Machine name	Enabled	Operations
    Document Cache	7.0.0	default	cache_document_default_7_0_0		Disable
    Field Value Cache	7.0.0	default	cache_fieldvalue_default_7_0_0		Disable
    Filter Cache	7.0.0	default	cache_filter_default_7_0_0		Disable
    Per Segment Filter Cache	7.0.0	default	cache_persegfilter_default_7_0_0		Disable
    Query Result Cache	7.0.0	default	cache_queryresult_default_7_0_0		Disable

    The following config schema work ok:
    /admin/reports/config-inspector/search_api_solr.solr_cache.cache_filter_default_7_0_0/list
    /admin/reports/config-inspector/search_api_solr.solr_cache.cache_queryresult_default_7_0_0/list
    /admin/reports/config-inspector/search_api_solr.solr_cache.cache_fieldvalue_default_7_0_0/list

    These ones don't

    /admin/reports/config-inspector/search_api_solr.solr_cache.cache_document_default_7_0_0/list
    /admin/reports/config-inspector/search_api_solr.solr_cache.cache_persegfilter_default_7_0_0/list

    see full error stack/log dump above.

  • 🇬🇧United Kingdom 2dareis2do

    working:

    langcode: en
    status: true
    dependencies:
      module:
        - search_api_solr
    id: cache_fieldvalue_default_7_0_0
    label: 'Field Value Cache'
    minimum_solr_version: 7.0.0
    environments: {}
    cache:
      name: fieldValue
      class: solr.FastLRUCache
      size: 512
      autowarmCount: 128
      showItems: 32
    solr_configs:
      query:
        -
          name: enableLazyFieldLoading
          VALUE: 'true'
    

    Not working

    langcode: en
    status: true
    dependencies:
      module:
        - search_api_solr
    id: cache_document_default_7_0_0
    label: 'Document Cache'
    minimum_solr_version: 7.0.0
    environments: {}
    cache:
      name: document
      class: solr.LRUCache
      size: 512
      initialSize: 512
      autowarmCount: 0
    
  • 🇬🇧United Kingdom 2dareis2do

    Issue fixed with this patch here

    https://www.drupal.org/project/drupal/issues/3364109 📌 Configuration schema & required values: add test coverage for `nullable: true` validation support Fixed

  • 🇧🇪Belgium wim leers Ghent 🇧🇪🇪🇺

    #15: what does that mean, that #3364109 fixed "the issue"? 📌 Configuration schema & required values: add test coverage for `nullable: true` validation support Fixed was committed to Drupal 10.3 and 11 on December 15 … and I guess I'm answering my own question: it sounds like this happens on Drupal 10.2, which doesn't have that addition.

    I'm currently investigating 📌 Expose validation constraint violations in Config Inspector UI and drush command Fixed , which should make Config Inspector work not crash on any config (even invalid config or config with invalid schema — note I'm not sure yet that is actually the case here, but I'm just stating that Config Inspector should always work and not crash 😊 — otherwise it's a bug in Config Inspector).

  • Status changed to Fixed 9 months ago
  • 🇧🇪Belgium wim leers Ghent 🇧🇪🇪🇺

    #16: found the answer: #3416934-23: Config Inspector crashes on 10.1.x + 10.2.x for `type: mapping` with `nullable: true` due to core bug .

    Work-around committed. In Drupal 10.3 and newer that work-around won't be necessary anymore 👍

  • 🇬🇧United Kingdom 2dareis2do

    Thank you

  • 🇩🇪Germany mkalkbrenner 🇩🇪

    Thank you!

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

Production build 0.71.5 2024