Follow-up for #3361534: Config validation errors can still occur for contrib modules, disrupting contrib

Created on 16 November 2023, 8 months ago
Updated 17 November 2023, 7 months ago

Problem/Motivation

Timeline:

  1. πŸ“Œ KernelTestBase::$strictConfigSchema = TRUE and BrowserTestBase::$strictConfigSchema = TRUE do not actually strictly validate Fixed brought config validation to tests.
  2. πŸ“Œ Follow-up for #3361534: config validation errors in contrib modules should cause deprecation notices, not test failures Fixed made it so that for contrib modules, only deprecation notices are shown (thanks to \Drupal\Core\Config\Schema\SchemaCheckTrait::isContribViolation()). @jibran confirmed that this fixed the test failures in https://www.drupal.org/project/dynamic_entity_reference β†’ πŸ‘

Problems:

  1. ⚠️ Even deprecation notices are too disruptive: (extracted out of πŸ“Œ Follow-up for #3361534: config validation errors in contrib modules should not cause deprecation notices, unless they opt in Active )
    πŸ‘† Fix.
  2. ⚠️😱 @Berdir discovered that the Webform tests are failing nonetheless in 10.2.x, see πŸ› [PP-2] to_email and similar config keys have schema type email but allow other things Needs work . So I automated testing that in πŸ“Œ Test Webform against upcoming 10.2.x on GitLab CI Needs review . The test results confirm what @Berdir said. Which makes this critical because it disrupts contrib significantly 😐
    πŸ‘† Fix.

Steps to reproduce

Proposed resolution

Remaining tasks

User interface changes

API changes

Data model changes

Release notes snippet

πŸ› Bug report
Status

Fixed

Version

10.2 ✨

Component
ConfigurationΒ  β†’

Last updated 25 minutes ago

Created by

πŸ‡§πŸ‡ͺBelgium Wim Leers Ghent πŸ‡§πŸ‡ͺπŸ‡ͺπŸ‡Ί

Live updates comments and jobs are added and updated live.
  • Contributed project blocker

    It denotes an issue that prevents porting of a contributed project to the stable version of Drupal due to missing APIs, regressions, and so on.

Sign in to follow issues

Comments & Activities

  • Issue created by @Wim Leers
  • πŸ‡¬πŸ‡§United Kingdom alexpott πŸ‡ͺπŸ‡ΊπŸŒ
  • πŸ‡¨πŸ‡­Switzerland Berdir Switzerland
  • πŸ‡¨πŸ‡­Switzerland bircher πŸ‡¨πŸ‡Ώ
  • πŸ‡§πŸ‡ͺBelgium borisson_ Mechelen, πŸ‡§πŸ‡ͺ
  • πŸ‡§πŸ‡ͺBelgium Wim Leers Ghent πŸ‡§πŸ‡ͺπŸ‡ͺπŸ‡Ί

    Determined the root cause:

      private function isContribViolation(): bool {
        $test_file_name = (new \ReflectionClass($this))->getFileName();
    …
    

    $this was assumed to be the test class. Unfortunately, this is inaccurate, because it depends on WHAT is calling
    \Drupal\Core\Config\Schema\SchemaCheckTrait::checkConfigSchema():

    OOPS 😱

    IMHO this is a 10.2.x beta blocker because virtually every contrib maintainer will run into this πŸ˜…πŸ™ˆ

  • @wim-leers opened merge request.
  • πŸ‡ΊπŸ‡ΈUnited States xjm
  • Status changed to Needs review 8 months ago
  • πŸ‡§πŸ‡ͺBelgium Wim Leers Ghent πŸ‡§πŸ‡ͺπŸ‡ͺπŸ‡Ί
    1. ⚠️😱 @Berdir discovered that the Webform tests are failing nonetheless in 10.2.x, see πŸ› [PP-2] to_email and similar config keys have schema type email but allow other things Needs work . So I automated testing that in πŸ“Œ Test Webform against upcoming 10.2.x on GitLab CI Needs review . The test results confirm what @Berdir said. Which makes this critical because it disrupts contrib significantly 😐

    πŸ‘† Fixed in https://git.drupalcode.org/project/drupal/-/merge_requests/5430/diffs?co...

  • Issue was unassigned.
  • πŸ‡§πŸ‡ͺBelgium Wim Leers Ghent πŸ‡§πŸ‡ͺπŸ‡ͺπŸ‡Ί
  • Status changed to Needs work 8 months ago
  • πŸ‡¬πŸ‡§United Kingdom alexpott πŸ‡ͺπŸ‡ΊπŸŒ

    I don't think this fix will work because the schema checker also runs in the site under test. See \Drupal\Core\Test\FunctionalTestSetupTrait::prepareSettings().

    We need to pass another argument into the testing.config_schema_checker service to determine whether to do config validation - this argument can be based on the test class.

  • Assigned to Wim Leers
  • πŸ‡§πŸ‡ͺBelgium Wim Leers Ghent πŸ‡§πŸ‡ͺπŸ‡ͺπŸ‡Ί

    I will run the Webform test suite against 10.2.x + this MR to verify.

  • πŸ‡§πŸ‡ͺBelgium Wim Leers Ghent πŸ‡§πŸ‡ͺπŸ‡ͺπŸ‡Ί

    First made the Webform test suite run much faster on GitLab CI, then used @Berdir's tip in Slack to automatically test with this MR on 10.2.

    Result:

    (Difference in output is due to switching from sequential to parallel test running per @Berdir in #6.

    Conclusion

    @alexpott was right in #3402168-12: Follow-up for #3361534: Config validation errors can still occur for contrib modules, disrupting contrib β†’ : the core MR does not yet fix it for functional tests.

    β€” #3402134-12: Test Webform against upcoming 10.2.x on GitLab CI β€” and use concurrency to make tests 6x faster β†’

    On it …

  • πŸ‡§πŸ‡ͺBelgium Wim Leers Ghent πŸ‡§πŸ‡ͺπŸ‡ͺπŸ‡Ί

    2926c398 is a hardening that fixes the incomplete detection logic, resulting in more functional tests passing, but not all:

    Drupal\Tests\webform\Functional\States\WebformStatesManagerT   1 passes                                      
    Drupal\Tests\webform\Functional\Variant\WebformVariantElemen   1 passes                                      
    Drupal\Tests\webform\Functional\States\WebformStatesHiddenTe   0 passes             1 exceptions             
    FATAL Drupal\Tests\webform\Functional\States\WebformStatesHiddenTest: test runner returned a non-zero error code (2).
    

    Now working on the actual bug that @alexpott pointed out, which only occurs if the the functional test is using the UI to make changes to config. This is true for \Drupal\Tests\webform\Functional\Settings\WebformSettingsSerialTest for example, which receives this HTML response:

    The website encountered an unexpected error. Try again later.<br><br><em class="placeholder">Drupal\Core\Config\Schema\SchemaIncompleteException</em>: Schema errors for webform.webform.contact with the following errors: 0 [handlers.email_confirmation.settings.to_mail] &amp;lt;em class=&amp;quot;placeholder&amp;quot;&amp;gt;&amp;amp;quot;[current-user:mail]&amp;amp;quot;&amp;lt;/em&amp;gt; is not a valid email address., 1 [handlers.email_confirmation.settings.from_mail] &amp;lt;em class=&amp;quot;placeholder&amp;quot;&amp;gt;&amp;amp;quot;_default&amp;amp;quot;&amp;lt;/em&amp;gt; is not a valid email address., 2 [handlers.email_notification.settings.to_mail] &amp;lt;em class=&amp;quot;placeholder&amp;quot;&amp;gt;&amp;amp;quot;_default&amp;amp;quot;&amp;lt;/em&amp;gt; is not a valid email address., 3 [handlers.email_notification.settings.from_mail] &amp;lt;em class=&amp;quot;placeholder&amp;quot;&amp;gt;&amp;amp;quot;[webform_submission:values:email:raw]&amp;amp;quot;&amp;lt;/em&amp;gt; is not a valid email address. in <em class="placeholder">Drupal\Core\Config\Development\ConfigSchemaChecker-&gt;onConfigSave()</em> (line <em class="placeholder">94</em> of <em class="placeholder">core/lib/Drupal/Core/Config/Development/ConfigSchemaChecker.php</em>). <pre class="backtrace">call_user_func(Array, Object, &#039;config.save&#039;, Object) (Line: 111)
    Drupal\Component\EventDispatcher\ContainerAwareEventDispatcher-&gt;dispatch(Object, &#039;config.save&#039;) (Line: 229)
    Drupal\Core\Config\Config-&gt;save() (Line: 278)
    Drupal\Core\Config\Entity\ConfigEntityStorage-&gt;doSave(&#039;contact&#039;, Object) (Line: 486)
    Drupal\Core\Entity\EntityStorageBase-&gt;save(Object) (Line: 257)
    Drupal\Core\Config\Entity\ConfigEntityStorage-&gt;save(Object) (Line: 108)
    Drupal\webform\WebformEntityStorage-&gt;save(Object) (Line: 352)
    Drupal\Core\Entity\EntityBase-&gt;save() (Line: 609)
    Drupal\Core\Config\Entity\ConfigEntityBase-&gt;save() (Line: 293)
    Drupal\Core\Entity\EntityForm-&gt;save(Array, Object) (Line: 50)
    Drupal\webform\EntitySettings\WebformEntitySettingsBaseForm-&gt;save(Array, Object) (Line: 847)
    Drupal\webform\EntitySettings\WebformEntitySettingsSubmissionsForm-&gt;save(Array, Object)
    …
    
  • @alexpott opened merge request.
  • Issue was unassigned.
  • Status changed to Needs review 7 months ago
  • πŸ‡§πŸ‡ͺBelgium Wim Leers Ghent πŸ‡§πŸ‡ͺπŸ‡ͺπŸ‡Ί

    c0ae1f84 made the Webform test suite pass β€” with the exception of unrelated failures (for example, WebformStatesHiddenTest and WebformSettingsPreviewTest fail because it's asserting markup literally instead of using CSS selectors, XPath or DOMDocument β€” probably these output changes are due to πŸ› Upgrade filter system to HTML5 Fixed ). See the results.

  • πŸ‡§πŸ‡ͺBelgium Wim Leers Ghent πŸ‡§πŸ‡ͺπŸ‡ͺπŸ‡Ί

    @alexpott's alternative MR looks much simpler and achieves the same. πŸ‘ I was just trying to minimize change, but I'm of course fine with his proposal.

    However, his proposal only fixes problem #2 in the issue summary, not problem #1 (i.e no deprecation error for contrib modules … at least not yet, because even that is considered too disruptive). The new name of the new argument he proposed is so strongly connected to deprecation errors that we're forced to. So my only concern with the MR is the $triggerDeprecationOnValidationError argument.

    Unless … @alexpott now thinks that the deprecation error is actually fine to keep? πŸ€”

  • πŸ‡§πŸ‡ͺBelgium Wim Leers Ghent πŸ‡§πŸ‡ͺπŸ‡ͺπŸ‡Ί

    Testing Alex' MR (commit: https://git.drupalcode.org/project/webform/-/merge_requests/380/diffs?co...), hopefully the results of his MR will match the results of my MR. (Which is possible despite his MR still triggering a deprecation error because Webform is suppressing deprecations.)

  • Status changed to RTBC 7 months ago
  • πŸ‡§πŸ‡ͺBelgium Wim Leers Ghent πŸ‡§πŸ‡ͺπŸ‡ͺπŸ‡Ί

    Cannot find a single remaining thing to complain about in @alexpott's alternate MR.

    The test results for webform on top of his MR still (see #17) match βœ…

    It's a very different approach from mine β€” much simpler, more explicit, less magic. πŸ‘ My only contribution to this MR is adding a data provider to the test.

  • Status changed to Needs work 7 months ago
  • πŸ‡§πŸ‡ͺBelgium Wim Leers Ghent πŸ‡§πŸ‡ͺπŸ‡ͺπŸ‡Ί

    … except that our YAML parsing of services.yml files does not quite like enums yet:

    1) Drupal\Tests\image\Functional\ImageDimensionsTest::testImageDimensions
    Symfony\Component\DependencyInjection\Exception\InvalidArgumentException: The file "/builds/project/drupal/sites/simpletest/75153141/services.yml" does not contain valid YAML: The string "!php/const Drupal\Core\Config\Schema\SchemaCheckConstraintValidation::Error" could not be parsed as a constant. Did you forget to pass the "Yaml::PARSE_CONSTANT" flag to the parser? at line 12 (near "testing.config_schema_checker: { class: Drupal\Core\Config\Development\ConfigSchemaChecker, arguments: ['@config.typed', [config_schema_test.no_schema, config_schema_test.some_schema, config_schema_test.schema_data_types, config_schema_test.no_schema_data_types, config_test.dynamic.system], !php/const Drupal\Core\Config\Schema\SchemaCheckConstraintValidation::Error], tags: [{ name: event_subscriber }] }")
    

    😬

  • πŸ‡§πŸ‡ͺBelgium Wim Leers Ghent πŸ‡§πŸ‡ͺπŸ‡ͺπŸ‡Ί
  • Status changed to RTBC 7 months ago
  • πŸ‡§πŸ‡ͺBelgium Wim Leers Ghent πŸ‡§πŸ‡ͺπŸ‡ͺπŸ‡Ί

    Ready now :)

    • catch β†’ committed 19acc1d5 on 10.2.x
      Issue #3402168 by Wim Leers, alexpott, Berdir, bircher, borisson_,...
    • catch β†’ committed c8b39f01 on 11.x
      Issue #3402168 by Wim Leers, alexpott, Berdir, bircher, borisson_,...
  • Status changed to Fixed 7 months ago
  • πŸ‡¬πŸ‡§United Kingdom catch

    This looks good, easy to follow the new logic and mostly moving things around otherwise. Committed/pushed to 11.x and cherry-picked to 10.2.x, thanks!

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

Production build 0.69.0 2024