Overview

Discovered while reviewing #3460230: Component entity config dependencies are incomplete: missing ComponentSourceInterface::calculateSettingsDependencies() to compute deps for field storage + instance settings + widget.

SdcPropKeysConstraintValidator::validate() should trigger a validation error when there's keys present in the given type: sequence that do not exist on the SDC. It currently does not:

Proposed resolution

  1. Fix the validator
  2. Add tests
  3. 🆗 Update ComponentValidationTest: it has 2 @todos pointing here. Recommendation: introduce a new xb_test_sdc:hero-with-cta test SDC. That'd then also allow removing the dependency on core's sdc_test module.#3503087: Disallow SDCs with `type: string, enum: …` with an empty string listed to convey optionality: the prop should then just be optional already did this!

User interface changes

None.

CommentFileSizeAuthor
Screenshot 2025-05-21 at 12.25.35 PM.png433.31 KBwim leers
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

wim leers created an issue. See original summary.

wim leers’s picture

None of the code in 0.x can generate this, it had to be manually constructed by @tedbow in a test.

Therefore, even sites created on beta1 should never run into this. Even if that's the case, the update path would be trivial 👍

wim leers’s picture

Issue summary: View changes
wim leers’s picture

Issue tags: -Needs update path +Novice

I think this is a great issue to start contributing to XB :)

meghasharma’s picture

Assigned: Unassigned » meghasharma

meghasharma’s picture

Assigned: meghasharma » Unassigned
Status: Active » Needs work

I updated the SdcPropKeysConstraintValidator::validate() method to check for extra keys in the input mapping that are not defined in the SDC props.
To support this, I added a new extraMessage property to the SdcPropKeysConstraint class for the error message.

wim leers’s picture

Issue summary: View changes

Looking good! That’s step 1 done 😄

Steps 2 and 3 are in the issue summary, do you think you could handle those too? 🙏

larowlan’s picture

I think is probably moot post #3528362: Deterministic Component version hash should depend not only on source-specific settings, but also slots + explicit input schema as the validation won't pass because the version doesn't match?

wim leers’s picture

🤔 I think it can still be wrong.

Because \Drupal\experience_builder\ComponentSource\ComponentSourceBase::generateVersionHash() looks at

    $normalized_data = [
      'settings' => $typed_source_specific_settings->toArray(),
      'slot_definitions' => $this instanceof ComponentSourceWithSlotsInterface
        ? self::normalizeSlotDefinitions($this->getSlotDefinitions())
        : [],
      'schema' => $this->getExplicitInputDefinitions(),
    ];

There's nothing preventing $typed_source_specific_settings to contain too much data — that'd just end up being hashed along with it; still resulting in a predictable version … just one based on mismatched settings.

In fact, \Drupal\Tests\experience_builder\Kernel\Config\ComponentValidationTest::setUp() proves that this is still the case.

wim leers’s picture

Given @larowlan's #9, I figured I'd just get this done 😇

wim leers’s picture

Status: Reviewed & tested by the community » Fixed

Thanks, @meghasharma, for getting this going! :)

Status: Fixed » Closed (fixed)

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