Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
jasonbuehler opened this issue Feb 6, 2024 · 1 comment
Open

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

jasonbuehler opened this issue Feb 6, 2024 · 1 comment

Comments

@jasonbuehler
Copy link

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.

  • shopify_api version: 13.4
  • Ruby version:
  • Operating system:

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
Copy link
Author

jasonbuehler commented Feb 7, 2024

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant