cloudevents / sdk-ruby

Ruby SDK for CloudEvents
Apache License 2.0
44 stars 13 forks source link

to_h does not perform a deep dup leaving the resulting hash partially frozen #43

Closed semmons99 closed 3 years ago

semmons99 commented 3 years ago

When calling to_hon an event, if the data attribute contains a nested hash, the nested hashes will remain frozen. To fix this we can use Marshal.load(Marshal.dump(@attributes)) instead of @attributes.dup. Alternatively, we could clone deep_dup from Rails, though it does miss some edge cases.

I have a PR prepared if you would like me to submit it.

dazuma commented 3 years ago

Thanks for the report! I've just been looking at some related fixes, and went ahead and threw this one in.

semmons99 commented 3 years ago

awesome, thank you.