Open philipgiuliani opened 9 months ago
The whole event looks like this:
%Commanded.EventStore.EventData{
causation_id: "281ca4b2-4ed4-4e9a-a4af-e31c4db5fc74",
correlation_id: "042f2ba4-6d12-4042-8103-41a32cee5976",
event_type: "Elixir.Dia.Projects.Events.AssistantRemoved",
data: %Dia.Projects.Events.AssistantRemoved{
assistant_id: "MA4676WJFGQZ",
applicant_id: "EPC244RCPCHZ",
id: "ef377a8b-0b86-4301-a864-6223352c710f"
},
metadata: %{
link: %Spear.Event{
id: "23aef121-84d2-4a3e-9689-bcec358d09ee",
type: "$>",
body: "3@test1708018151-beneficiary-MA4676WJFGQZ",
link: nil,
metadata: %{
created: ~U[2024-02-15 17:29:14.825739Z],
content_type: "application/octet-stream",
stream_name: "$ce-test1708018151",
prepare_position: 76359753,
commit_position: 76359753,
custom_metadata: "{\"$v\":\"3:-1:1:4\",\"$c\":76359446,\"$p\":76359446,\"$o\":\"test1708018151-beneficiary-MA4676WJFGQZ\",\"$causedBy\":\"b71573d9-e0f4-466e-adc3-d0a88a316154\",\"$correlationId\":\"042f2ba4-6d12-4042-8103-41a32cee5976\"}",
stream_revision: 9
}
}
}
}
I wasn't able to understand this code well enough. In the meanwhile I added an ugly try/rescue and the system seems to behave correctly.
custom_metadata =
if event_type == "$>" do
""
else
try do
serialize_metadata(event, serializer)
rescue
_ ->
""
end
It looks like, somehow the metadata ended up containing a link (Spear.Event).
Can you check if replacing metadata
in https://github.com/fabriziosestito/commanded-spear-adapter/blob/fcf18250f28ce495688ba2257108d9c15e29d8a7/lib/commanded/event_store/adapters/spear/mapper.ex#L173 with
(metadata != nil && Map.reject(metadata, fn {_, value} -> is_struct(value, Spear.Event) end))
fixes the issue?
In the latest version in master there is a problem with the system events again. When deleting an event, the following error comes up:
These errors were fixed with https://github.com/fabriziosestito/commanded-spear-adapter/issues/10 before. /cc @dvic