Skip to content

ShopifyAPI::Webhooks::Registry.add_registration occurred TypeError in fields parameter #1147

@m11o

Description

@m11o

Issue summary

We passed array of strings to fields parameter in ShopifyAPI::Webhooks::Registry.add_registration in order to filter received fields for collections_update webhook topic. But, it got TypeError.
it should be able to receive T.any(String, T::Array[String]). But, it set T.nilable(String) .

  • shopify_api version: 12.2.1
  • Ruby version: 2.7.6
  • Operating system: Mac OS
Traceback (most recent call last):
	51: from bin/rails:4:in `<main>'
	50: from bin/rails:4:in `require'
	49: from /Users/m11o/stamps/vendor/bundle/ruby/2.7.0/gems/railties-6.1.7.3/lib/rails/commands.rb:18:in `<top (required)>'
	48: from /Users/m11o/stamps/vendor/bundle/ruby/2.7.0/gems/railties-6.1.7.3/lib/rails/command.rb:48:in `invoke'
	47: from /Users/m11o/stamps/vendor/bundle/ruby/2.7.0/gems/railties-6.1.7.3/lib/rails/command/base.rb:69:in `perform'
	46: from /Users/m11o/stamps/vendor/bundle/ruby/2.7.0/gems/thor-1.1.0/lib/thor.rb:392:in `dispatch'
	45: from /Users/m11o/stamps/vendor/bundle/ruby/2.7.0/gems/thor-1.1.0/lib/thor/invocation.rb:127:in `invoke_command'
	44: from /Users/m11o/stamps/vendor/bundle/ruby/2.7.0/gems/thor-1.1.0/lib/thor/command.rb:27:in `run'
	43: from /Users/m11o/stamps/vendor/bundle/ruby/2.7.0/gems/railties-6.1.7.3/lib/rails/commands/console/console_command.rb:101:in `perform'
	42: from /Users/m11o/stamps/vendor/bundle/ruby/2.7.0/gems/railties-6.1.7.3/lib/rails/command/actions.rb:15:in `require_application_and_environment!'
	41: from /Users/m11o/stamps/vendor/bundle/ruby/2.7.0/gems/railties-6.1.7.3/lib/rails/command/actions.rb:28:in `require_environment!'
	40: from /Users/m11o/stamps/vendor/bundle/ruby/2.7.0/gems/railties-6.1.7.3/lib/rails/application.rb:367:in `require_environment!'
	39: from /Users/m11o/stamps/vendor/bundle/ruby/2.7.0/gems/activesupport-6.1.7.3/lib/active_support/dependencies.rb:332:in `require'
	38: from /Users/m11o/stamps/vendor/bundle/ruby/2.7.0/gems/activesupport-6.1.7.3/lib/active_support/dependencies.rb:299:in `load_dependency'
	37: from /Users/m11o/stamps/vendor/bundle/ruby/2.7.0/gems/activesupport-6.1.7.3/lib/active_support/dependencies.rb:332:in `block in require'
	36: from /Users/m11o/stamps/vendor/bundle/ruby/2.7.0/gems/zeitwerk-2.6.6/lib/zeitwerk/kernel.rb:38:in `require'
	35: from /Users/m11o/stamps/vendor/bundle/ruby/2.7.0/gems/zeitwerk-2.6.6/lib/zeitwerk/kernel.rb:38:in `require'
	34: from /Users/m11o/stamps/config/environment.rb:5:in `<top (required)>'
	33: from /Users/m11o/stamps/vendor/bundle/ruby/2.7.0/gems/railties-6.1.7.3/lib/rails/application.rb:391:in `initialize!'
	32: from /Users/m11o/stamps/vendor/bundle/ruby/2.7.0/gems/railties-6.1.7.3/lib/rails/initializable.rb:60:in `run_initializers'
	31: from /Users/m11o/.rbenv/versions/2.7.6/lib/ruby/2.7.0/tsort.rb:205:in `tsort_each'
	30: from /Users/m11o/.rbenv/versions/2.7.6/lib/ruby/2.7.0/tsort.rb:226:in `tsort_each'
	29: from /Users/m11o/.rbenv/versions/2.7.6/lib/ruby/2.7.0/tsort.rb:347:in `each_strongly_connected_component'
	28: from /Users/m11o/.rbenv/versions/2.7.6/lib/ruby/2.7.0/tsort.rb:347:in `call'
	27: from /Users/m11o/.rbenv/versions/2.7.6/lib/ruby/2.7.0/tsort.rb:347:in `each'
	26: from /Users/m11o/.rbenv/versions/2.7.6/lib/ruby/2.7.0/tsort.rb:349:in `block in each_strongly_connected_component'
	25: from /Users/m11o/.rbenv/versions/2.7.6/lib/ruby/2.7.0/tsort.rb:431:in `each_strongly_connected_component_from'
	24: from /Users/m11o/.rbenv/versions/2.7.6/lib/ruby/2.7.0/tsort.rb:350:in `block (2 levels) in each_strongly_connected_component'
	23: from /Users/m11o/.rbenv/versions/2.7.6/lib/ruby/2.7.0/tsort.rb:228:in `block in tsort_each'
	22: from /Users/m11o/stamps/vendor/bundle/ruby/2.7.0/gems/railties-6.1.7.3/lib/rails/initializable.rb:61:in `block in run_initializers'
	21: from /Users/m11o/stamps/vendor/bundle/ruby/2.7.0/gems/railties-6.1.7.3/lib/rails/initializable.rb:32:in `run'
	20: from /Users/m11o/stamps/vendor/bundle/ruby/2.7.0/gems/railties-6.1.7.3/lib/rails/initializable.rb:32:in `instance_exec'
	19: from /Users/m11o/stamps/vendor/bundle/ruby/2.7.0/gems/railties-6.1.7.3/lib/rails/application/finisher.rb:140:in `block in <module:Finisher>'
	18: from /Users/m11o/stamps/vendor/bundle/ruby/2.7.0/gems/activesupport-6.1.7.3/lib/active_support/lazy_load_hooks.rb:51:in `run_load_hooks'
	17: from /Users/m11o/stamps/vendor/bundle/ruby/2.7.0/gems/activesupport-6.1.7.3/lib/active_support/lazy_load_hooks.rb:51:in `each'
	16: from /Users/m11o/stamps/vendor/bundle/ruby/2.7.0/gems/activesupport-6.1.7.3/lib/active_support/lazy_load_hooks.rb:52:in `block in run_load_hooks'
	15: from /Users/m11o/stamps/vendor/bundle/ruby/2.7.0/gems/activesupport-6.1.7.3/lib/active_support/lazy_load_hooks.rb:66:in `execute_hook'
	14: from /Users/m11o/stamps/vendor/bundle/ruby/2.7.0/gems/activesupport-6.1.7.3/lib/active_support/lazy_load_hooks.rb:61:in `with_execution_control'
	13: from /Users/m11o/stamps/vendor/bundle/ruby/2.7.0/gems/activesupport-6.1.7.3/lib/active_support/lazy_load_hooks.rb:68:in `block in execute_hook'
	12: from /Users/m11o/stamps/shopify/config/initializers/shopify_app.rb:74:in `block in <top (required)>'
	11: from /Users/m11o/stamps/vendor/bundle/ruby/2.7.0/gems/shopify_app-21.1.1/lib/shopify_app/managers/webhooks_manager.rb:40:in `add_registrations'
	10: from /Users/m11o/stamps/vendor/bundle/ruby/2.7.0/gems/shopify_app-21.1.1/lib/shopify_app/managers/webhooks_manager.rb:40:in `each'
	 9: from /Users/m11o/stamps/vendor/bundle/ruby/2.7.0/gems/shopify_app-21.1.1/lib/shopify_app/managers/webhooks_manager.rb:43:in `block in add_registrations'
	 8: from /Users/m11o/stamps/vendor/bundle/ruby/2.7.0/gems/sorbet-runtime-0.5.10324/lib/types/private/methods/call_validation.rb:89:in `block in create_validator_slow'
	 7: from /Users/m11o/stamps/vendor/bundle/ruby/2.7.0/gems/sorbet-runtime-0.5.10324/lib/types/private/methods/call_validation.rb:113:in `validate_call'
	 6: from /Users/m11o/stamps/vendor/bundle/ruby/2.7.0/gems/sorbet-runtime-0.5.10324/lib/types/private/methods/signature.rb:206:in `each_args_value_type'
	 5: from /Users/m11o/stamps/vendor/bundle/ruby/2.7.0/gems/sorbet-runtime-0.5.10324/lib/types/private/methods/signature.rb:206:in `each'
	 4: from /Users/m11o/stamps/vendor/bundle/ruby/2.7.0/gems/sorbet-runtime-0.5.10324/lib/types/private/methods/signature.rb:211:in `block in each_args_value_type'
	 3: from /Users/m11o/stamps/vendor/bundle/ruby/2.7.0/gems/sorbet-runtime-0.5.10324/lib/types/private/methods/call_validation.rb:116:in `block in validate_call'
	 2: from /Users/m11o/stamps/vendor/bundle/ruby/2.7.0/gems/sorbet-runtime-0.5.10324/lib/types/private/methods/call_validation.rb:187:in `report_error'
	 1: from /Users/m11o/stamps/vendor/bundle/ruby/2.7.0/gems/sorbet-runtime-0.5.10324/lib/types/configuration.rb:303:in `call_validation_error_handler'
/Users/m11o/stamps/vendor/bundle/ruby/2.7.0/gems/sorbet-runtime-0.5.10324/lib/types/configuration.rb:296:in `call_validation_error_handler_default': Parameter 'fields': Expected type T.nilable(String), got type Array with value ["id", "title", "handle", "...emplate_suffix", "updated_at"] (TypeError)
Caller: /Users/m11o/stamps/vendor/bundle/ruby/2.7.0/gems/sorbet-runtime-0.5.10324/lib/types/private/methods/call_validation.rb:113
Definition: /Users/m11o/stamps/vendor/bundle/ruby/2.7.0/gems/shopify_api-12.2.1/lib/shopify_api/webhooks/registry.rb:18

Expected behavior

In Shopify Admin API, WebhookSubscriptionInput.includeFields can receive array of fields. (doc)
ShopifyAPI::Webhooks::Registry.add_registration can receive array of fields, not occur TypeError.

ShopifyAPI::Webhooks::Registry.add_registration(
  topic: 'collections_update',
  delivery_method: :http,
  path: 'hoge/path',
  handler: CollectionsUpdateJob,
  fields: ['id', 'title', 'handle'],
)

Actual behavior

ShopifyAPI::Webhooks::Registry.add_registration occurred TypeError when passing array of fields to it.

Steps to reproduce the problem

  1. Set array of fields in ShopifyAPI::Webhooks::Registry.add_registration

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions