You are setting a key that conflicts with a built-in method Hashie::Mash#object_id
key88sf opened this issue · 8 comments
When calling Shippo::Shipment.create(...)
with the latest version of the gem (2.0.8), we are now seeing this warning in the rails output log/console:
You are setting a key that conflicts with a built-in method Hashie::Mash#object_id defined in Kernel. This can cause unexpected behavior when accessing the key via as a property. You can still access the key via the #[] method.
Seems dangerous :)
I've run into this before on #47, and it appears to just be a warning from the Hashie gem. It seems so prevalent that they added in the ability to suppress those warning in v3.5.2.
It looks like we might not be suppressing the warnings everywhere we can, so we'll need to take a deeper dive into finding out what is triggering these warning to generate and either address it or suppress it.
Any update on this? This is a big concern for us as far as integrating with Shippo goes.
We are looking further into this. I am not super versed in Ruby, but I think it has to do with https://github.com/goshippo/shippo-ruby-client/blob/master/lib/shippo/api/resource.rb#L72
We have this scheduled in our next sprint to be reviewed further though.
I think they fixed this in 3.x ?
So we already flag Hashie to suppress warning but they are still showing in the logs there. We're going to look further into why they are showing and getting them to not show going forward.
Took a quick look and this seems to be because Hashie::Mash is still used here before the merge: https://github.com/goshippo/shippo-ruby-client/blob/master/lib/shippo/api/resource.rb#L57
I think subclassing that, possiblly as a Shippo::API::ApiHash class from which Shippo::API::Resource can inherit, is preferable to setting the global Hashie.logger to nil.
It may be overkill and I have to admit I'm not familiar with this gem's overall architecture, but, for example: goatapp@8140b2d
Looks like this has been fixed. Closing.