Bundle update - ArgumentError - high level rule

#1

This code was previously tested and working until a bundle update today.

Version changes (working -> not working):

dry-configurable 0.7.0 -> 0.8.2
dry-container 0.6.0 -> 0.7.0
dry-equalizer 0.2.1 -> 0.2.2
dry-logic 0.4.2 -> 0.6.0
dry-types 0.13.4 -> 0.14.1
dry-validation 0.12.2 -> 0.13.3

From the debugger, it breaks on next_not_active:

validation schema: Validations::Schema, with: {form: true} do
  configure do

    def has_next?
      # errors.add(:next, 'There is no existing downgrade to cancel') unless model.next
      !form.model.next.nil?
    end

    def is_downgrade?
      # protect against non-downgrade next.  if next is an upgrade, this would destroy critical data.
      # errors.add(:next, "The subscription to be used on #{model.next.start_at} is not a downgrade")
      form.model.plan.is_downgrade?(form.model.next.plan)
    end

    def next_not_active?
      # protect against destroying active next subscriptions (considering the history is fully linked together)
      #errors.add(:next, 'The subscription is already active and cannot be canceled in this manner')
      form.model.next.uninitialized? || form.model.next.future_active?
    end
  end

  rule(:can_cancel) do
    has_next? && is_downgrade? && next_not_active?
  end
end

Error snippet:

ArgumentError: wrong number of arguments (given 1, expected 0)

  0) system behaves like subscription: active downgrade cancel_downgrade
     Failure/Error: Subscription::CancelDowngrade.(params: {id: subscription.id})
     
     ArgumentError:
       wrong number of arguments (given 1, expected 0)
     Shared Example Group: "subscription: active downgrade" called from ./spec/app/models/subscription_system/active_downgrade_spec.rb:6
     # /Users/kross/.rvm/gems/ruby-2.6.0@af/gems/dry-logic-0.6.0/lib/dry/logic/rule/interface.rb:102:in `call'
     # /Users/kross/.rvm/gems/ruby-2.6.0@af/gems/dry-validation-0.13.1/lib/dry/validation/executor.rb:48:in `block (2 levels) in call'
     # /Users/kross/.rvm/gems/ruby-2.6.0@af/gems/dry-validation-0.13.1/lib/dry/validation/executor.rb:47:in `each'
     # /Users/kross/.rvm/gems/ruby-2.6.0@af/gems/dry-validation-0.13.1/lib/dry/validation/executor.rb:47:in `block in call'
     # /Users/kross/.rvm/gems/ruby-2.6.0@af/gems/dry-validation-0.13.1/lib/dry/validation/executor.rb:46:in `each'
     # /Users/kross/.rvm/gems/ruby-2.6.0@af/gems/dry-validation-0.13.1/lib/dry/validation/executor.rb:46:in `each_with_object'
     # /Users/kross/.rvm/gems/ruby-2.6.0@af/gems/dry-validation-0.13.1/lib/dry/validation/executor.rb:46:in `call'
     # /Users/kross/.rvm/gems/ruby-2.6.0@af/gems/dry-validation-0.13.1/lib/dry/validation/executor.rb:85:in `block in call'
     # /Users/kross/.rvm/gems/ruby-2.6.0@af/gems/dry-validation-0.13.1/lib/dry/validation/executor.rb:83:in `each'
     # /Users/kross/.rvm/gems/ruby-2.6.0@af/gems/dry-validation-0.13.1/lib/dry/validation/executor.rb:83:in `reduce'
     # /Users/kross/.rvm/gems/ruby-2.6.0@af/gems/dry-validation-0.13.1/lib/dry/validation/executor.rb:83:in `call'
     # /Users/kross/.rvm/gems/ruby-2.6.0@af/gems/dry-validation-0.13.1/lib/dry/validation/schema.rb:72:in `call'
     # /Users/kross/.rvm/gems/ruby-2.6.0@af/gems/reform-2.3.0.rc1/lib/reform/form/dry.rb:59:in `call_schema'
     # /Users/kross/.rvm/gems/ruby-2.6.0@af/gems/reform-2.3.0.rc1/lib/reform/form/dry.rb:50:in `call'

TL;DR

  1. I looked at the release notes/change logs and nothing jumped out at me
  2. I double checked the docs, and high level rules still look the same.

Is there a gem incompatibility? do I need to lock something down? Or increase range specifier and update my syntax?

0 Likes

#2

If anyone else finds this, for the moment I had to pin dry-logic < 0.6.0 for the moment.

0 Likes

#3

The problem is that the schema will try to pass can_cancel to the has_next?, is_downgrade? and next_not_active? methods.

One way you can work around it is to have and a parameter to the methods

1 Like

#4

Thanks, that worked.

0 Likes

#5

I addressed it in dry-logic 0.6.1 https://github.com/dry-rb/dry-logic/releases/tag/v0.6.1

0 Likes