diff --git a/store/memory.go b/store/memory.go index 8c0bcde..13d5286 100644 --- a/store/memory.go +++ b/store/memory.go @@ -24,12 +24,20 @@ func NewInMemoryEventStore() *InMemoryEventStore { // deepCopyEvent creates a deep copy of an event to ensure immutability. // This prevents modifications to the event after it's been persisted. +// Panics if JSON marshaling/unmarshaling fails, which should never occur +// for a valid Event structure. func deepCopyEvent(event *aether.Event) *aether.Event { // Use JSON marshaling/unmarshaling for a complete deep copy // This ensures all nested structures (maps, slices) are copied - data, _ := json.Marshal(event) + data, err := json.Marshal(event) + if err != nil { + panic("failed to marshal event: " + err.Error()) + } var copy aether.Event - json.Unmarshal(data, ©) + err = json.Unmarshal(data, ©) + if err != nil { + panic("failed to unmarshal event: " + err.Error()) + } // Preserve empty metadata maps (JSON unmarshal converts empty map to nil) if event.Metadata != nil && len(event.Metadata) == 0 && copy.Metadata == nil {