Skip to content

Commit

Permalink
syslog: Handle ValueError raised while sending logs to syslog (ansibl…
Browse files Browse the repository at this point in the history
…e#82225)

* ValueError exception is raised when Null Character is sent
  to syslog.syslog with Python 3.12.
* Handle this error gracefully instead of stacktrace

Signed-off-by: Abhijeet Kasurde <[email protected]>
  • Loading branch information
Akasurde authored Nov 16, 2023
1 parent 1a75965 commit 8fd1aa0
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
3 changes: 3 additions & 0 deletions changelogs/fragments/syslog_exception.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
---
bugfixes:
- syslog - Handle ValueError exception raised when sending Null Characters to syslog with Python 3.12.
2 changes: 1 addition & 1 deletion lib/ansible/module_utils/basic.py
Original file line number Diff line number Diff line change
Expand Up @@ -1269,7 +1269,7 @@ def _log_to_syslog(self, msg):
facility = getattr(syslog, self._syslog_facility, syslog.LOG_USER)
syslog.openlog(str(module), 0, facility)
syslog.syslog(syslog.LOG_INFO, msg)
except TypeError as e:
except (TypeError, ValueError) as e:
self.fail_json(
msg='Failed to log to syslog (%s). To proceed anyway, '
'disable syslog logging by setting no_target_syslog '
Expand Down

0 comments on commit 8fd1aa0

Please sign in to comment.