Merging Hashes

Just wondering if anyone could help with merging of hashes.

I am attempting to take a given node object and copy it to a hash:

vars = node.test.to_hash

Then I have a data bag with similar keys/values as the node.test object.

“id”: “mydbag”,
“default”: {
“var1”: “value1”,
“var2”: “value2”

So the default in attributes for node.test.var1 = "value_1"
And the data bag is var1 => value1

I want to be able to vars.deep_merge!(dbag[“default”]) but every time I try Chef throws

Chef::Exceptions::ImmutableAttributeModification: Node attributes are read-only when you do not specify which precedence level to set. To set an attribute use code like `node.default[“key”] = “value”’

vars.class returns Hash as expected and not a node object so why the Exception?

Any way around this?