Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

!!! FEATURE: Add workspaceName to relevant events #5002

Merged
merged 21 commits into from
May 18, 2024

Conversation

bwaidelich
Copy link
Member

@bwaidelich bwaidelich commented Apr 19, 2024

Adds the workspaceName to the data of all content stream related events.

Breaking change

This is a breaking change because it changes the event payload.
Exports need to be replaced and events can be migrated with the provided event migration:

Event migration

This PR comes with a event migration that allows for fixing already published events:

./flow migrateevents:migratePayloadToWorkspaceName

Resolves: #4996

@github-actions github-actions bot added the 9.0 label Apr 19, 2024
# Conflicts:
#	Neos.ContentRepository.Core/Classes/Feature/NodeMove/Event/NodeAggregateWasMoved.php
@bwaidelich bwaidelich changed the title WIP: FEATURE: Add workspaceName to relevant events !!! FEATURE: Add workspaceName to relevant events May 17, 2024
@bwaidelich bwaidelich marked this pull request as ready for review May 17, 2024 13:14
Copy link
Member Author

@bwaidelich bwaidelich left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I left some comments for my fellow reviewers..

Apart from those I wonder if we need to take care of previous CR exports, e.g. via some on-the-fly-migration during import!?

@@ -38,13 +38,13 @@ public static function enrichWithCommand(
foreach ($events as $event) {
if ($event instanceof DecoratedEvent) {
$undecoratedEvent = $event->innerEvent;
if (!$undecoratedEvent instanceof PublishableToOtherContentStreamsInterface) {
if (!$undecoratedEvent instanceof PublishableToWorkspaceInterface) {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I renamed the interface PublishableToOtherContentStreamsInterface to PublishableToWorkspaceInterface

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oh yes that was missed with bernhards change :D

Comment on lines +434 to +435
$contentGraph->getWorkspaceName(),
$contentGraph->getContentStreamId(),
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Previously the contentStreamId was taken from the node aggregate – but since that does not contain the workspaceName I changed both to use the info from the ContentGraph.
Not 100% sure about this, but in practice it should not make a difference

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

actually that seems like the best option as NodeAggregate::contentStreamId will be removed.

Comment on lines 97 to 99
if (!isset($eventPayload['workspaceName'])) {
$eventPayload['workspaceName'] = 'some-workspace';
}
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I used this in all the "The event [...] was published with payload" steps to fill the workspaceName if it wasn't specified (we already do that for dimension space points etc).

An alternative would be to adjust the behat tests themselves.. not sure about it

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

auto fill seems fine. dont we do this with the csid as well?

Copy link
Member

@nezaniel nezaniel May 18, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We used to fall back to currentContentStreamId and could do the same with currentWorkspaceName. I'm not too fond of autofill here and would prefer an exception if neither is given

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oh lol sorry i missed that we literally hardcode 'some-workspace' here. I was under impression we would fallback to currentWorkspaceName which i also prefer ;)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it's because it does not matter in the cases. But I agree that we should be specific here, I'll adjust the tests and require the workspace name to be set

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

phew, that was tedious but I think I adjusted all affected tests (let's see what the CI says)
I love our tests, but IMO we test too much from the _event_s perspective (there are 83 hits for /the event .* was published with payload/). IMO we should mostly execute commands and expect events and/or state as a result (except for the rare low-level cases that are not feasible to recreate with commands).. But that's for another time :)

Copy link
Member

@mhsdesign mhsdesign May 18, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thx ❤️, Yes i have an issue as reminder for that: #4336

but i was under the impression that most things now use commands already.

Copy link
Member

@mhsdesign mhsdesign left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tested with migrating the Neos Ui e2e events and running the ui e2e tests as well.

We also have to adjust our 3 event export:

  • Neos.Demo
  • Neos ui testcase twodimension
  • Neos ui testcase onedimension

i would propose to just edit the workspace live in there so its easy to review the changes.

@bwaidelich
Copy link
Member Author

@mhsdesign thanks for the feedback, I'll take care of a follow-up.

We also have to adjust our 3 event export

Not sure if I got that.. Is that something that can be done in this PR directly or is that Neos UI?

@mhsdesign
Copy link
Member

Okay, so the migration will def take some time like a good minute for 19k events.
but what surprises me that it says Migration applied to 13320 events, while i do have 19.433?

@mhsdesign
Copy link
Member

nevermind. I oversaw the continue;

Copy link
Member

@mhsdesign mhsdesign left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oke seems to work. There will definitely be a lot of missing's depending on how many node migrations you did ... or maybe there is something wrong. Hard to tell because the events dont tell me why this change was made.

There is an initiating user id set? So not cli + node migration? If that is true and you also have preservations we should maybe reconsider.

On the otherhand ill +1 this and well see if there are bugs once this is in use by projections at first.

@bwaidelich
Copy link
Member Author

There is an initiating user id set? So not cli + node migration? If that is true and you also have preservations we should maybe reconsider.

I read that three times but still don't understand it ;)

@mhsdesign
Copy link
Member

what i meant @bwaidelich, what do you think lead to this event:

payload:

{
  "contentStreamId": "9cc426e4-3520-4e48-8272-609267850177",
  "nodeAggregateId": "6b6e1251-4346-494f-ac56-526a30a5741d",
  "originDimensionSpacePoint": {
    "language": "pl"
  },
  "affectedDimensionSpacePoints": [
    {
      "language": "pl"
    }
  ],
  "propertyValues": {
    "uriPathSegment": {
      "value": "laszelechow",
      "type": "string"
    }
  },
  "propertiesToUnset": [],
  "workspaceName": "missing"
}

metadata

{
  "commandClass": "Neos\\ContentRepository\\Core\\Feature\\NodeModification\\Command\\SetSerializedNodeProperties",
  "commandPayload": {
    "nodeAggregateId": "6b6e1251-4346-494f-ac56-526a30a5741d",
    "originDimensionSpacePoint": {
      "language": "pl"
    },
    "propertyValues": {
      "uriPathSegment": {
        "value": "laszelechow",
        "type": "string"
      }
    },
    "propertiesToUnset": [],
    "workspaceName": "missing:9cc426e4-3520-4e48-8272-609267850177"
  },
  "initiatingUserId": "3e5ed99c-16e4-4a12-a23b-4489563e85e7",
  "initiatingTimestamp": "2023-11-07T23:16:15+00:00"
}

@bwaidelich
Copy link
Member Author

what do you think lead to this event

@mhsdesign Uh, no idea. But if no corresponding workspace was created before, it should have never happened to begin with.
I guess that's no longer possible with the current version.
And it's not directly related to this PR, is it?

@mhsdesign
Copy link
Member

mhsdesign commented May 17, 2024

And it's not directly related to this PR, is it?

only kindof, i feared we did something wrong that i have so many "workspaceName": "missing" were in my routes.

But as said i think there is no bug on our side. I just kindof fear that there might be the need to be some $workspaceName === 'missing' in php? But we cant do anything against it.

Every code must assume that the workspace name is no longer valid either way so +1.

@mhsdesign mhsdesign requested a review from nezaniel May 18, 2024 07:01
@kitsunet
Copy link
Member

kitsunet commented May 18, 2024

For the shown event were does the workspaceName come from there? As in, where is this event created code wise?

@mhsdesign
Copy link
Member

For the shown event were does the workspaceName come from there? As in, where is this event created code wise?

that is the problem due to missing metadata we dont surely now but i suspect from previous structure adjustments or more likely node migrations (@dlubitz mentioned they operate currently on cs instead of ws and that is what he is about to change: #4685)

@kitsunet
Copy link
Member

Neither of those would have a user ID though? I rather meant what event is it and which command handler creates it...

@mhsdesign
Copy link
Member

Neither of those would have a user ID though? I rather meant what event is it and which command handler creates it...

yeah thats the thing that makes me rethink this as well. Its a properties was set event: (but you should have the same db dump as well)

17,Workspace:user-jon,2,WorkspaceWasRebased
18,ContentStream:33edf226-c93d-4243-8769-619977fb0c39,1,NodePropertiesWereSet
19,ContentStream:9cc426e4-3520-4e48-8272-609267850177,0,ContentStreamWasForked
20,ContentStream:9cc426e4-3520-4e48-8272-609267850177,1,NodePropertiesWereSet
21,ContentStream:90bcfbf8-c444-48f8-9911-ba0954ac795a,0,ContentStreamWasForked
22,ContentStream:63d38bd9-453e-4af1-8625-848716678038,10,NodePropertiesWereSet
23,ContentStream:9cc426e4-3520-4e48-8272-609267850177,2,ContentStreamWasRemoved

(the above is event 20)

Copy link
Member

@kitsunet kitsunet left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So much details, thank you for going through it all.

@kitsunet kitsunet merged commit d10bc0f into 9.0 May 18, 2024
10 checks passed
@kitsunet kitsunet deleted the feature/4996-add-workspacename-to-events branch May 18, 2024 19:39
@mhsdesign
Copy link
Member

We also have to adjust our 3 event export

Not sure if I got that.. Is that something that can be done in this PR directly or is that Neos UI?

I meant these three json l:

all adjusted ;)

mhsdesign added a commit to mhsdesign/neos-development-collection that referenced this pull request Jun 19, 2024
With neos#5002 `\Neos\Neos\FrontendRouting\Projection\DocumentUriPathFinder::isLiveContentStream` is obsolete.
neos-bot pushed a commit to neos/neos that referenced this pull request Sep 25, 2024
With neos/neos-development-collection#5002 `\Neos\Neos\FrontendRouting\Projection\DocumentUriPathFinder::isLiveContentStream` is obsolete.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

Add workspaceName to relevant events
4 participants