-
Notifications
You must be signed in to change notification settings - Fork 681
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
After inspec update from 1.5 to 1.10 it breaks with [undefined method `[]=' for nil:NilClass] #1456
Comments
I have this problem on inspec 1.14.0 too, Here is the replication case: https://github.com/artem-sidorenko/inspec-test |
I wonder somehow that I'm the only one who reports this problem, I tried it in a sane environment via installing the last gems and can see this problem: $ gem install test-kitchen
$ gem install kitchen-inspec
$ gem install berkshelf
$ gem install kitchen-vagrant @arlimus @chris-rock do I miss something here? Can you reproduce this problem? Is it a problem? |
I have the same issue as well, if it's any consolation. The only real difference is I'm running in ChefDK (version 1.2.22) with kitchen-inspec (the version of inspec in kitchen 1.15.0). I have two paths for tests as well, and I've even tried it with adding a name to the second path:
|
@Paladin great! I'm not alone and its even confirmed on chefdk :) |
Hi friends! Thanks for the report! I'll be looking at this either today or Monday. I can confirm that I can reproduce this with @artem-sidorenko's repro repository and the latest ChefDK. |
Found an interesting tweak: If you change the path to point to specific test files (path/to/test/test.rb) you lose the undefined method error. Seems only to be an issue if you pass a directory. Given that and a few other cues I saw, similar to 1392 I'm wondering if this also isn't a bug coming from the reporter, instead of the verifier? |
Issue is in the rspec json formatter within InSpec itself. When it goes to add the example to the control, the control itself is nil and has not yet been created. This only appears to happen for a particular test, not all of them. Still digging into why that is the case. I'll have more to share soon. |
I've found the issue here. When you're not using a full compliance profile but rather raw controls, InSpec essentially creates a profile for you under the covers. When the formatter runs, it tries to tie examples back to a given profile. In this case, the example has a nil profile ID, and the profile itself has no name (which is used as the ID). When we get to the second set of tests, InSpec was incorrectly matching the tests from the second group to the first group. This caused InSpec to create a nil Control reporter object and then throw the error you've experienced. I believe I have a fix which involves not attempting to match to a profile if either the profile ID in the example is nil, or if the profile itself is nil. This should still allow raw controls to work while still maintaining the reportability of the full compliance profiles. /cc @arlimus |
Interesting. I was on my way back with further info I'd dug out over lunch when I read this, and it fits with what you wrote in the notes above. Given: If the first file has empty versions of every control set given in every test file you want to include (essentially naming the controls right at the start) execution w/no error. Take even one control out of that first file (even if it's one from a file that has multiple sets) and the method missing error returns. These results are consistent with yours (and your thought also explains why listing only the individual test files used in a particular suite rather than a full directory triggers the same missing method error) so I'm thinking you're right on target. And I'm also thinking I should start adding profiles (they didn't exist when this particular repo was started, so they're not there). |
@artem-sidorenko and @Paladin: I've opened #1488 to correct this issue. |
@adamleff cool, thank you! |
@artem-sidorenko and @Paladin the PR fixing this has been merged to master. Feel free to give it a try, but we also plan on cutting a new release of InSpec on Monday which will include the fix. Thanks for your patience! |
@adamleff thank you for fixing this :) |
Description
inspec breaks with
undefined method []=' for nil:NilClass
after the update inspec 1.5.0 -> 1.10.0InSpec and Platform Version
Replication Case
I could not easily replicate the problem, but it looks like there is a relation to the multiple test sets in the
.kitchen.yml
:If I leave only one path there -> it works
UPDATE: replication case is here: https://github.com/artem-sidorenko/inspec-test
Stacktrace
The text was updated successfully, but these errors were encountered: