Overview

found in #3460856: Create validation constraint for ComponentTreeStructure

$component_id = $tree->getComponentId($component_instance_uuid);
      try {
        $props_values = $value->resolveComponentProps($component_instance_uuid);
        $component = $this->componentPluginManager->find($component_id);
        $this->componentValidator->validateProps($props_values, $component);
      }

$props_values = $value->resolveComponentProps($component_instance_uuid); will throw an exception if
the component does not exist or it does exist but there are no props for the component in the props value. But not all components will have props. It could just have slots or I guess could have neither if props or slots.

#3460856 we have to fix the problem of the component not existing at all but here we should set up a test case where the component has no props

Proposed resolution

Check if the component has props defined before trying resolving them.

User interface changes

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

tedbow created an issue. See original summary.

wim leers’s picture

Issue tags: +Needs tests

See core/modules/system/tests/modules/sdc_test/components/no-props/no-props.component.yml for an example of a propless SDC.

So yes, this is intended to work. And we should have an explicit test for it. 👍

wim leers’s picture

Assigned: Unassigned » wim leers

Getting a test going.

wim leers’s picture

Assigned: wim leers » Unassigned
Status: Active » Needs work
Issue tags: -Needs tests

Test exists now. And it fails as expected.

Note that the proposed resolution presents

Check if the component has props defined before trying resolving them.

as the only possible choice.

But there's another possible choice: storing an empty list of props even for propless component instances. It keeps the structure simpler and non-conditional. I think that would make future component upgrade paths simpler (e.g. for adding props to a component that is already in use — which #3452756: Ensure querying JSON nested values when parent keys are unknown is possible in all supported databases is laying the groundwork for).

The cost of that simplicity is slightly more storage space being consumed, because there's additional JSON to be stored.

wim leers’s picture

Title: ValidComponentTreeConstraintValidator assumes all components have props » Support propless SDCs
Issue tags: +Novice

Thanks to the draft MR I pushed, with clear @todos, I think this is now actionable by novice contributors.

wim leers’s picture

tedbow’s picture

Assigned: tedbow » wim leers
Status: Needs work » Needs review
wim leers’s picture

Assigned: wim leers » tedbow
Status: Needs review » Needs work
wim leers’s picture

Assigned: tedbow » utkarsh_33
wim leers’s picture

Assigned: utkarsh_33 » Unassigned
Issue tags: -blocker

Doesn't need to be @Utkarsh_33 who works on this :)

cosmicdreams’s picture

It sounds like what is left for this issue is to get it to pass the tests.

wim leers’s picture

Assigned: Unassigned » wim leers

With ~1 month of changes, I think a rebase is necessary.

wim leers’s picture

Assigned: wim leers » Unassigned

Merged in upstream, looks like more tests than before are failing.

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

wim leers’s picture

Category: Bug report » Task
deepakkm’s picture

Assigned: Unassigned » deepakkm
deepakkm’s picture

Status: Needs work » Needs review
wim leers’s picture

Status: Needs review » Needs work

@deepakkm: Only two nits for you to address, then it's up to @tedbow to review :)

deepakkm’s picture

Assigned: deepakkm » tedbow
Status: Needs work » Needs review
tedbow’s picture

Assigned: tedbow » deepakkm
Status: Needs review » Needs work
deepakkm’s picture

Assigned: deepakkm » wim leers
Status: Needs work » Needs review

Feedback changes done.

wim leers’s picture

Assigned: wim leers » deepakkm
Status: Needs review » Needs work

The code that was added is inappropriately expanding the API surface, and it's too open-ended. Please tighten it 🙏

tedbow’s picture

Assigned: deepakkm » wim leers
Status: Needs work » Needs review
wim leers’s picture

Assigned: wim leers » Unassigned
Status: Needs review » Reviewed & tested by the community

I cannot approve this MR because I started this MR.

Up to you to decide whether this is ready to be merged, @tedbow :)

tedbow’s picture

@wim leers thanks

I merged in 0.x. Will merge MR if tests pass

tedbow’s picture

Assigned: Unassigned » tedbow
wim leers’s picture

Assigned: tedbow » Unassigned

Needs Felix' sign-off for

Config management
/tests/src/Kernel/ComponentTest.php

… but the changes there are trivial.

So: bypassing review and merging 🚢

  • wim leers committed e13eb45d on 0.x
    Issue #3463188 by deepakkm, tedbow, wim leers: Support propless SDCs
    
wim leers’s picture

Status: Reviewed & tested by the community » Fixed

Status: Fixed » Closed (fixed)

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