mirror of
https://github.com/zitadel/zitadel.git
synced 2025-11-02 07:58:46 +00:00
fix(actions v2): send event_payload on event executions again (#10669)
# Which Problems Are Solved
It was noticed that on actions v2 when subscribing to events, the
webhook would always receive an empty `event_payload`:
```
{
"aggregateID": "336494809936035843",
"aggregateType": "user",
"resourceOwner": "336392597046099971",
"instanceID": "336392597046034435",
"version": "v2",
"sequence": 1,
"event_type": "user.human.added",
"created_at": "2025-09-05T08:55:36.156333Z",
"userID": "336392597046755331",
"event_payload":
{}
}
```
The problem was due to using `json.Marshal` on the `Event` interface,
where the underlying `BaseEvent` prevents the data to be marshalled:
131f70db34/internal/eventstore/event_base.go (L38)
# How the Problems Are Solved
The `Event`s `Unmarshal` function is used with a `json.RawMessage`.
# Additional Changes
none
# Additional Context
- backport for v4.x
- relates to https://github.com/zitadel/zitadel/pull/10651
- relates to https://github.com/zitadel/zitadel/pull/10564
This commit is contained in:
@@ -262,8 +262,8 @@ func Test_mapCommands(t *testing.T) {
|
||||
|
||||
func TestEventstore_queueExecutions(t *testing.T) {
|
||||
events := []eventstore.Event{
|
||||
mockEventType(mockAggregate("TEST"), 1, nil, "ex.foo.bar"),
|
||||
mockEventType(mockAggregate("TEST"), 2, nil, "ex.bar.foo"),
|
||||
mockEventType(mockAggregate("TEST"), 1, []byte(`{"test":"test"}`), "ex.foo.bar"),
|
||||
mockEventType(mockAggregate("TEST"), 2, []byte("{}"), "ex.bar.foo"),
|
||||
mockEventType(mockAggregate("TEST"), 3, nil, "ex.removed"),
|
||||
}
|
||||
type args struct {
|
||||
|
||||
@@ -27,10 +27,13 @@ func NewRequest(e eventstore.Event, targets []target.Target) (*Request, error) {
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
eventData, err := json.Marshal(e)
|
||||
// The underlying BaseEvent omits the data when using json.Marshal so we have to unmarshal it manually.
|
||||
var eventData json.RawMessage
|
||||
err = e.Unmarshal(&eventData)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return &Request{
|
||||
Aggregate: e.Aggregate(),
|
||||
Sequence: e.Sequence(),
|
||||
|
||||
Reference in New Issue
Block a user