Skip to content

Commit

Permalink
fix(homebrew): give correct error message when become true used (#8048)
Browse files Browse the repository at this point in the history
* fix(homebrew): give correct error message when become true used

This commit fixes #8047 by raising the exception coming from calling
homebrew with the `become: true` parameter set.

* chore(changelog): add changelog fragment
  • Loading branch information
thewalla07 authored Mar 8, 2024
1 parent 98df344 commit fa30b02
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
bugfixes:
- homebrew - error returned from brew command was ignored and tried to parse empty JSON. Fix now checks for an error and raises it to give accurate error message to users (https://github.com/ansible-collections/community.general/issues/8047).
4 changes: 4 additions & 0 deletions plugins/modules/homebrew.py
Original file line number Diff line number Diff line change
Expand Up @@ -488,6 +488,10 @@ def _current_package_is_installed(self):
self.current_package,
]
rc, out, err = self.module.run_command(cmd)
if err:
self.failed = True
self.message = err.strip()
raise HomebrewException(self.message)
data = json.loads(out)

return _check_package_in_json(data, "formulae") or _check_package_in_json(data, "casks")
Expand Down

0 comments on commit fa30b02

Please sign in to comment.