1
0
Fork 0
mirror of https://github.com/ansible-collections/community.general.git synced 2024-09-14 20:13:21 +02:00

[PR #8048/fa30b022 backport][stable-7] fix(homebrew): give correct error message when become true used (#8067)

fix(homebrew): give correct error message when become true used (#8048)

* 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

(cherry picked from commit fa30b02294)

Co-authored-by: Michael Wall <thewalla07@gmail.com>
This commit is contained in:
patchback[bot] 2024-03-09 12:42:25 +00:00 committed by GitHub
parent ddf566a729
commit a73404ae3f
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 6 additions and 0 deletions

View file

@ -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).

View file

@ -488,6 +488,10 @@ class Homebrew(object):
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")