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

Check stdout even when exit_status is 0, and handle JSON.parse exception #601

Merged
merged 5 commits into from
Oct 1, 2020

Conversation

CodesWhisperer
Copy link
Contributor

Description

When the target is a cisco_ios device, the exit_status is 0 but the error is described in the stdout, so the if condition doesn't work and the JSON.parse raises an exception.

Also, the JSON.parse should always be in rescue block.

Related Issue

#599

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New content (non-breaking change)
  • Breaking change (a content change which would break existing functionality or processes)

Checklist:

  • I have read the CONTRIBUTING document.

@CodesWhisperer CodesWhisperer requested a review from a team as a code owner May 25, 2020 09:35
@chef-expeditor
Copy link
Contributor

Hello CodesWhisperer! Thanks for the pull request!

Here is what will happen next:

  1. Your PR will be reviewed by the maintainers.
  2. Possible Outcomes
    a. If everything looks good, one of them will approve it, and your PR will be merged.
    b. The maintainer may request follow-on work (e.g. code fix, linting, etc). We would encourage you to address this work in 2-3 business days to keep the conversation going and to get your contribution in sooner.
    c. Cases exist where a PR is neither aligned to Chef InSpec's product roadmap, or something the team can own or maintain long-term. In these cases, the maintainer will provide justification and close out the PR.

Thank you for contributing!

@clintoncwolfe
Copy link
Contributor

Code looks reasonable to me, just need to get it past the linter. Also please sign your commit to indicate acceptance of our contribution terms - https://github.com/inspec/train/blob/master/CONTRIBUTING.md#developer-certification-of-origin-dco

@CodesWhisperer CodesWhisperer force-pushed the master branch 2 times, most recently from ca0e6e2 to 142c22a Compare June 2, 2020 07:04
@CodesWhisperer
Copy link
Contributor Author

@clintoncwolfe
I fixed it, but the tests "tests-ruby-2.6-windows" didn't pass and I don't know why.

@clintoncwolfe
Copy link
Contributor

The gem ffi segfaults under windows right now. We have a pending PR to pin the version back to a working version. Once that merges you can rebase to master and the windows tests should pass.

@james-stocks
Copy link

Hi @CodesWhisperer -

This looks good, thank you! I left one comment suggesting to make the code easier to understand; because in future an issue may occur with some other platform; and the logic might get changed in a way that fixes that other platform but causes Cisco to start failing again...

As Clinton said, please rebase this branch against master to get the Windows tests working.

Thanks

@tas50
Copy link
Contributor

tas50 commented Jun 18, 2020

@CodesWhisperer Can you rebase this against master please?

@rmoles
Copy link

rmoles commented Aug 10, 2020

It would be good to get this merged. Could you rebase against master @CodesWhisperer ?

CodesWhisperer and others added 2 commits September 23, 2020 13:13
When the target is a cisco_ios device, the exit_status is 0 but the error is described in the stdout, so the if condition doesn't work and the JSON.parse raises an exception.

The JSON.parse should always be in rescue block.

Signed-off-by: CodesWhisperer <[email protected]>
Signed-off-by: CodesWhisperer <[email protected]>
@rmoles
Copy link

rmoles commented Sep 23, 2020

@CodesWhisperer unfortunately your last commit is missing your DCO, could you please push another commit with your DCO added?

@CodesWhisperer
Copy link
Contributor Author

@rmoles Is it good?

@rmoles
Copy link

rmoles commented Oct 1, 2020

Awesome thanks @CodesWhisperer. Unfortunately, I don't have merge rights on this repo. Perhaps, @james-stocks or @Schwad can merge this.

@james-stocks
Copy link

Thanks for this @CodesWhisperer !

@james-stocks james-stocks merged commit cd0cf40 into inspec:master Oct 1, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants