fail!
raises self, which is an OpenStruct and to_s
on the exception loads ActiveRecord Relations
#185
Labels
fail!
raises self, which is an OpenStruct and to_s
on the exception loads ActiveRecord Relations
#185
We recently updated the interactor gem and ran into an interesting issue where
fail!
would trigger any ActiveRecord relations passed in the context to be evaluated.The issue ended up being because of a rescue in one of our interactors doing
exception.to_s
'. And because the context is an OpenStruct,to_s
would print out the results of the ActiveRecord relations because for each key, it doesvalue.inspect
Here is a very simple reproduction that works in console.
The fix we are using is adding a
to_s
in Interactor::Failure. If someone wants to access the context, it's already on Failure here: https://github.com/collectiveidea/interactor/blob/master/lib/interactor/error.rb#L27Would this fix be something you are interested in having a Pull Request for? If so I can submit one.
Thanks
The text was updated successfully, but these errors were encountered: