Shopify / shopify-api-ruby

ShopifyAPI is a lightweight gem for accessing the Shopify admin REST and GraphQL web services.
MIT License
1.06k stars 473 forks source link

obj.respond_to? :method_name isn't working correctly #1273

Open jasonbuehler opened 9 months ago

jasonbuehler commented 9 months ago

Issue summary

When using api_object.respond_to?(:method_name) the lib sometimes returns true and sometimes returns T::Private::Types::Void::VOID Sorbet private void type. It seems that true was returned if the method name had been previously used to dereference the object but on more inspection I am not so sure that's the case.

Expected behavior

When calling respond_to? with a method name the object should return true if the object is able to respond to the method call or false if it is not, and if you call the method name on the object after it returns false it should raise a NoMethodError

Actual behavior

Sometimes the response is true, sometimes it's a private Sorbet type T::Private::Types::Void::VOID, and sometimes it switches from the private type to true after you dereference the object with the method in question.

Steps to reproduce the problem

  1. Instantiate an api object (I used a product)
  2. Invoke respond_to? on it ( api_object.respond_to? :some_bs_method )
  3. Bonus points - try invoking the method on the object after receiving the Sorbet type as a response and then calling respond_to? with the method name, it was returning true for me after doing so
jasonbuehler commented 9 months ago

Thanks @matteodepalo , I appreciate it! I have also been seeing other cases of api calls returning the Sorbet private VOID type, such as when I update an api order object using .save (REST), not sure if that's also related, but it doesn't seem like that type should really ever be returned from a method. Not sure if mentioning it here is sufficient or if I should be opening another ticket for that as well, seems like it could also be related to this.