Overview

Discovered in #3500083: Managing components sourced as code components which was doing a PATCH request to rename a code component. The request only sent the name and id. Because \Drupal\experience_builder\Controller\ApiConfigControllers::patch called \Drupal\experience_builder\Entity\JavaScriptComponent::denormalizeFromClientSide with the data from the client and that method has lines like 'props' => $data['props'] ?? [], which will wipe out the props if it was not sent from the client

Proposed resolution

Don't require the client to send all the keys. Maybe add an optional $entity argument to denormalizeFromClientSide that would set on PATCH requests

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

@hoorooomoo was the one to discover it, crediting them :)

balintbrews’s picture

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

longwave’s picture

Assigned: Unassigned » longwave

denormalizeFromClientSide() doesn't have to be static, instead we can convert it to an instance method that updates the instance directly.

longwave’s picture

Status: Active » Needs work

MR as POC of #6, still needs additional test coverage.

longwave’s picture

Status: Needs work » Needs review
Issue tags: -Needs tests
longwave’s picture

Assigned: longwave » Unassigned
tedbow’s picture

Assigned: Unassigned » tedbow

Reviewing

tedbow’s picture

Assigned: tedbow » Unassigned
Status: Needs review » Needs work

Reviewing

longwave’s picture

Assigned: Unassigned » longwave
wim leers’s picture

Additional feedback. 🏓

wim leers’s picture

Issue tags: +stable blocker

Also, what a major oversight of mine! 🫣😬

longwave’s picture

Assigned: longwave » Unassigned
Status: Needs work » Needs review

I think the CodeComponents POST vs PATCH solution is relatively neat but wondering what other opinions are.

It's a shame really that we have to do some of this mapping in the first place, and that we use id and machineName interchangeably, and similarly name and label. Should we try to clean this up before we have a stable API?

effulgentsia’s picture

Issue tags: +sprint
wim leers’s picture

Assigned: Unassigned » longwave
Status: Needs review » Needs work
Issue tags: +openapi

One more set of OpenAPI adjustments needed, then this will be RTBC.

It's a shame really that we have to do some of this mapping in the first place, and that we use id and machineName interchangeably, and similarly name and label. Should we try to clean this up before we have a stable API?

The idea/intent was that the client-side and server-side can evolve independently. Same spirit as docs/adr/0005-Keep-the-front-end-simple.md, but applied to XB's config, instead of XB's component tree data model on the server (must juggle a lot of complexity) vs client (very little complexity).

I do agree there's relatively little value in it, but also not that much harm/complexity.

No strong feelings, but perhaps the argument should be that the client MUST be kept in sync to avoid the renaming on the server side, because that does not cause significant complexity on the client?

longwave’s picture

Assigned: longwave » Unassigned
Status: Needs work » Needs review

No strong feelings either, just the usual "naming things is hard" argument - although I hope this decision doesn't come to bite us in the future.

Added NewAssetLibrary and NewPattern schemas and removed the separate hardcoded schemas for the POST cases.

wim leers’s picture

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

No strong feelings either, just the usual "naming things is hard" argument

💯

although I hope this decision doesn't come to bite us in the future.

What decision in particular do you fear potential consequences for?

Is it https://git.drupalcode.org/project/experience_builder/-/merge_requests/8...?

AFAICT you solved both mine and @tedbow's concerns? 😄

RTBC'ing and assigning to @tedbow because I sense I'm missing something… 🫣

  • tedbow committed a580e4d6 on 0.x authored by longwave
    Issue #3508140 by longwave, wim leers, tedbow, hooroomoo, balintbrews:...
tedbow’s picture

Status: Reviewed & tested by the community » Fixed

Thanks all!

tedbow’s picture

Assigned: tedbow » Unassigned
nagwani’s picture

Issue tags: -sprint

Status: Fixed » Closed (fixed)

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