Skip to content
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

reject nil as a command input #1863

Merged
merged 1 commit into from
Jun 19, 2017
Merged

reject nil as a command input #1863

merged 1 commit into from
Jun 19, 2017

Conversation

arlimus
Copy link
Contributor

@arlimus arlimus commented May 30, 2017

It is not valid and the errors get very cryptic once it passes train and goes to the various backends. Let's just catch it early on. It is a user error that should be avoided.

@arlimus arlimus added the Type: Bug Feature not working as expected label May 30, 2017
@arlimus arlimus force-pushed the dr/cmd-nil-fix branch 3 times, most recently from b8e63c0 to 5a425a1 Compare May 31, 2017 05:52
Copy link
Contributor

@adamleff adamleff left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Love the change @arlimus but wonder if we should place it elsewhere.

@@ -28,6 +28,9 @@ def initialize(cmd)
end

def result
if @command.nil?
raise 'InSpec `command` was called with `nil` as the argument. This is not supported. Please provide a valid command instead.'
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This feels like it belongs in #initialize since no method in this resource should work / will work with a nil command. Is there a technical reason you put it here instead of in the constructor?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lets make it skip the command resource for now until we have proper exception handling

Copy link
Contributor Author

@arlimus arlimus Jun 3, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually, let's not skip. Skip points to unsupported use on a platform, at least in the current context. This however is a full user-error and should never be done this way. It's like adding nil to a number ;) We need the exception handling piece but it needs to fail afaics.
I can move it to initialize as well, will update this pr...

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@arlimus this will stop inspec profile execution, even if you have multiple profiles in execution

Signed-off-by: Dominik Richter <dominik.richter@gmail.com>
Copy link
Contributor

@adamleff adamleff left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Even though we try to avoid calling raise because it will unwind the whole run, I feel like an issue like this is worthy of it as it points to an implementation issue vs. an error on the target. This will obviously get better once we implement better exception handling.

@adamleff adamleff merged commit 3f68835 into master Jun 19, 2017
@miah miah deleted the dr/cmd-nil-fix branch May 3, 2019 22:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Type: Bug Feature not working as expected
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants