Regression caused by #3493943: example/default image in SDC no longer loads

Created on 3 April 2025, 16 days ago

Overview

When testing with the image-optional-with-example-and-additional-prop
SDC that 🐛 Default image is lost after changing props Active added:

AKA the component does not render at all :O

This is despite \Drupal\Tests\experience_builder\Kernel\ApiLayoutControllerPostTest::testImageComponentPermutations() still passing tests.

Proposed resolution

TBD

User interface changes

None.

🐛 Bug report
Status

Active

Version

0.0

Component

Component sources

Created by

🇧🇪Belgium wim leers Ghent 🇧🇪🇪🇺

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

Merge Requests

Comments & Activities

  • Issue created by @wim leers
  • 🇧🇪Belgium wim leers Ghent 🇧🇪🇪🇺

    Maybe this is caused by the logic in workaroundAddDefaultValuesMissingFromClientSideModel() having been moved into \Drupal\experience_builder\Plugin\ExperienceBuilder\ComponentSource\GeneratedFieldExplicitInputUxComponentSourceBase::clientModelToInput() and then tweaked:

         foreach (($client_model['source'] ?? []) as $prop => $prop_source) {
    -      if ($violations === NULL && !\array_key_exists($prop, $client_model['resolved'])) {
    -        // Valueless prop, for the case where only a default is provided for the
    -        // preview, not for storing.
    -        // @see ::exampleValueRequiresEntity()
    -        // @see ::getClientSideInfo()
    

    to:

    +      catch (\OutOfRangeException | \OutOfBoundsException) {
    +        if (($violations === NULL ||
    +          (\array_key_exists('value', $prop_source) && $prop_source['value'] === $default_source_value)) &&
    +          !empty($prop_value)) {
    +          // Valueless prop, for the case where only a default is provided for
    +          // the preview or the initial state of the component inputs form, but
    +          // not for storing.
    +          // @see ::exampleValueRequiresEntity()
    +          // @see ::getClientSideInfo()
    

    In there, $default_source_value === [], but $prop_source['value'] === NULL, so the branch is never entered.

    Quoting the best most precise comment that explains this:

            // The empty array is stored to signal this is an SDC prop (optional or
            // required) whose example value would need an entity to be created,
            // which is not allowed.
            // @see ::exampleValueRequiresEntity()
            [] => FALSE,
    
  • 🇧🇪Belgium wim leers Ghent 🇧🇪🇪🇺

    As I dug into this, it seems that the problem is bigger still: it seems you cannot actually add image-optional-with-example-and-additional-prop nor image-optional-without-exampleto the canvas anymore:

    index.js?v=1:150 Uncaught TypeError: Cannot read properties of undefined (reading 'resolved')
        at index.js?v=1:150:82549
        at Array.forEach (<anonymous>)
        at s (index.js?v=1:150:82482)
        at index.js?v=1:150:82941
        at index.js?v=1:52:19682
        at index.js?v=1:235:21188
        at It.<anonymous> (index.js?v=1:235:21575)
        at _Fe (index.js?v=1:183:10830)
        at Gs (index.js?v=1:183:11430)
        at It._onDrop (index.js?v=1:183:27942)
    

    which is this line:

              // These will be needed when we support client-side preview updates.
              initialData.resolved[propName] = prop.default_values.resolved;
    

    which was modified in 📌 Split model values into resolved and raw Active , which appears to previously have been relying on a fallback.

  • First commit to issue fork.
  • 🇦🇺Australia larowlan 🇦🇺🏝.au GMT+10

    We have an e2e for this and it is passing in HEAD https://git.drupalcode.org/project/experience_builder/-/jobs/4864263#L1774

    And I just verified it locally

    Ah, but that's a required image - not optional.

    Picking this up

  • 🇦🇺Australia larowlan 🇦🇺🏝.au GMT+10

    So turns out the issue was in the line of code we were iffy about in the review!

    Added some fixes and a test 🤞

  • Merge request !845Issue #3517102 Fix image regression → (Merged) created by larowlan
  • Pipeline finished with Success
    15 days ago
    Total: 1512s
    #464958
  • 🇦🇺Australia larowlan 🇦🇺🏝.au GMT+10

    Green first time, must be my lucky day!

  • 🇧🇪Belgium wim leers Ghent 🇧🇪🇪🇺

    So turns out the issue was in the line of code we were iffy about in the review!

    HAH! 😄 I should've thought of that when I wrote #2! (Hope that still helped narrow it down though.

    This MR looks perfect.

  • Pipeline finished with Skipped
    15 days ago
    #465265
  • Pipeline finished with Skipped
    15 days ago
    #465268
  • 🇧🇪Belgium wim leers Ghent 🇧🇪🇪🇺
Production build 0.71.5 2024