sparkleformation / sfn

SparkleFormation CLI
http://www.sparkleformation.io
Apache License 2.0
63 stars 24 forks source link

AWS planner crashes with NoMethodError in diff_init #291

Closed dualbus closed 5 years ago

dualbus commented 5 years ago

I created a test case to reproduce the issue in the following PR - https://github.com/sparkleformation/sfn/pull/290

The stack trace is:

    NoMethodError: undefined method `last' for nil:NilClass
        /home/dualbus/src/sparkleformation/sfn/lib/sfn/planner/aws.rb:518:in `block in diff_init'
        /home/dualbus/src/sparkleformation/sfn/lib/sfn/planner/aws.rb:513:in `tap'
        /home/dualbus/src/sparkleformation/sfn/lib/sfn/planner/aws.rb:513:in `diff_init'
        /home/dualbus/src/sparkleformation/sfn/lib/sfn/planner/aws.rb:541:in `register_diff'
        /home/dualbus/src/sparkleformation/sfn/lib/sfn/planner/aws.rb:447:in `block in run_stack_diff'
        /home/dualbus/src/sparkleformation/sfn/lib/sfn/planner/aws.rb:446:in `each'
        /home/dualbus/src/sparkleformation/sfn/lib/sfn/planner/aws.rb:446:in `run_stack_diff'
        /home/dualbus/src/sparkleformation/sfn/lib/sfn/planner/aws.rb:374:in `plan_stack'
        /home/dualbus/src/sparkleformation/sfn/lib/sfn/planner/aws.rb:252:in `generate_plan'
        /home/dualbus/src/sparkleformation/sfn/test/specs/planner_spec.rb:485:in `block (5 levels) in <top (required)>'
        /usr/lib/ruby/vendor_ruby/minitest/test.rb:98:in `block (3 levels) in run'
        /usr/lib/ruby/vendor_ruby/minitest/test.rb:195:in `capture_exceptions'
        /usr/lib/ruby/vendor_ruby/minitest/test.rb:95:in `block (2 levels) in run'
        /usr/lib/ruby/vendor_ruby/minitest.rb:265:in `time_it'
        /usr/lib/ruby/vendor_ruby/minitest/test.rb:94:in `block in run'
        /usr/lib/ruby/vendor_ruby/minitest.rb:360:in `on_signal'
        /usr/lib/ruby/vendor_ruby/minitest/test.rb:211:in `with_info_handler'
        /usr/lib/ruby/vendor_ruby/minitest/test.rb:93:in `run'
        /usr/lib/ruby/vendor_ruby/minitest.rb:960:in `run_one_method'
        /usr/lib/ruby/vendor_ruby/minitest.rb:334:in `run_one_method'
        /usr/lib/ruby/vendor_ruby/minitest.rb:321:in `block (2 levels) in run'
        /usr/lib/ruby/vendor_ruby/minitest.rb:320:in `each'
        /usr/lib/ruby/vendor_ruby/minitest.rb:320:in `block in run'
        /usr/lib/ruby/vendor_ruby/minitest.rb:360:in `on_signal'
        /usr/lib/ruby/vendor_ruby/minitest.rb:347:in `with_info_handler'
        /usr/lib/ruby/vendor_ruby/minitest.rb:319:in `run'
        /usr/lib/ruby/vendor_ruby/minitest.rb:159:in `block in __run'
        /usr/lib/ruby/vendor_ruby/minitest.rb:159:in `map'
        /usr/lib/ruby/vendor_ruby/minitest.rb:159:in `__run'
        /usr/lib/ruby/vendor_ruby/minitest.rb:136:in `run'
        /usr/lib/ruby/vendor_ruby/minitest.rb:63:in `block in autorun'

This happens due to diff_init not knowing how to handle a diff that includes two deletions (diff.size > 1), e.g.

[["-", "Parameters.Param.AllowedValues[5]", "1"], ["-", "Parameters.Param.AllowedValues[5]", "5"]]
chrisroberts commented 5 years ago

Fixed with #290. Thanks again!

dualbus commented 5 years ago

Wow, thank you for fixing this so quickly and for your great work on sparkleformation!