sparkleformation / sfn

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

Add test case for `NoMethodError` crash in diff_init #290

Closed dualbus closed 5 years ago

dualbus commented 5 years ago

The stack trace of the error:

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'
dualbus commented 5 years ago

OK, so the CI failure is expected, since this is just the test case without an actual fix:

Finished in 8.082930s, 10.6397 runs/s, 30.9294 assertions/s.
  1) Error:
Sfn::Planner::Sfn::Planner::Aws::Parameters AllowedValues::AllowedValues have a different order#test_0001_does not crash with: NoMethodError: undefined method `last' for nil:NilClass:
NoMethodError: undefined method `last' for nil:NilClass
    /home/travis/build/sparkleformation/sfn/lib/sfn/planner/aws.rb:518:in `block in diff_init'
    /home/travis/build/sparkleformation/sfn/lib/sfn/planner/aws.rb:513:in `tap'
    /home/travis/build/sparkleformation/sfn/lib/sfn/planner/aws.rb:513:in `diff_init'
    /home/travis/build/sparkleformation/sfn/lib/sfn/planner/aws.rb:541:in `register_diff'
    /home/travis/build/sparkleformation/sfn/lib/sfn/planner/aws.rb:447:in `block in run_stack_diff'
    /home/travis/build/sparkleformation/sfn/lib/sfn/planner/aws.rb:446:in `each'
    /home/travis/build/sparkleformation/sfn/lib/sfn/planner/aws.rb:446:in `run_stack_diff'
    /home/travis/build/sparkleformation/sfn/lib/sfn/planner/aws.rb:374:in `plan_stack'
    /home/travis/build/sparkleformation/sfn/lib/sfn/planner/aws.rb:252:in `generate_plan'
    /home/travis/build/sparkleformation/sfn/test/specs/planner_spec.rb:485:in `block (5 levels) in <top (required)>'
86 runs, 250 assertions, 0 failures, 1 errors, 1 skips

Let me know if you want me to also send a fix for this. I'd need some help understanding how diff_init should behave with arrays though.

chrisroberts commented 5 years ago

@dualbus Thanks for reporting this and the PR with reproduction!