diff --git a/NEWS b/NEWS index 7e4112129..923338269 100644 --- a/NEWS +++ b/NEWS @@ -1,3 +1,6 @@ +1.4.16 + * Fix for missing Healthchecks monitoring payload or HTTP 500 due to incorrect unicode encoding. + 1.4.15 * Fix for database dump removal incorrectly skipping some database dumps. * #123: Support for mounting an archive as a FUSE filesystem via "borgmatic mount" action, and diff --git a/borgmatic/hooks/healthchecks.py b/borgmatic/hooks/healthchecks.py index 19201d0f0..a116205a8 100644 --- a/borgmatic/hooks/healthchecks.py +++ b/borgmatic/hooks/healthchecks.py @@ -97,4 +97,4 @@ def ping_monitor(ping_url_or_uuid, config_filename, state, dry_run): if not dry_run: logging.getLogger('urllib3').setLevel(logging.ERROR) - requests.post(ping_url, data=payload) + requests.post(ping_url, data=payload.encode('utf-8')) diff --git a/setup.py b/setup.py index cf16442ab..46871a9cc 100644 --- a/setup.py +++ b/setup.py @@ -1,6 +1,6 @@ from setuptools import find_packages, setup -VERSION = '1.4.15' +VERSION = '1.4.16' setup( diff --git a/tests/unit/hooks/test_healthchecks.py b/tests/unit/hooks/test_healthchecks.py index cbb9cc76a..24e8fca06 100644 --- a/tests/unit/hooks/test_healthchecks.py +++ b/tests/unit/hooks/test_healthchecks.py @@ -60,7 +60,7 @@ def test_ping_monitor_hits_ping_url_for_start_state(): flexmock(module).should_receive('Forgetful_buffering_handler') ping_url = 'https://example.com' flexmock(module.requests).should_receive('post').with_args( - '{}/{}'.format(ping_url, 'start'), data='' + '{}/{}'.format(ping_url, 'start'), data=''.encode('utf-8') ) module.ping_monitor(ping_url, 'config.yaml', state=module.monitor.State.START, dry_run=False) @@ -68,19 +68,21 @@ def test_ping_monitor_hits_ping_url_for_start_state(): def test_ping_monitor_hits_ping_url_for_finish_state(): ping_url = 'https://example.com' - payload = flexmock() + payload = 'data' flexmock(module).should_receive('format_buffered_logs_for_payload').and_return(payload) - flexmock(module.requests).should_receive('post').with_args(ping_url, data=payload) + flexmock(module.requests).should_receive('post').with_args( + ping_url, data=payload.encode('utf-8') + ) module.ping_monitor(ping_url, 'config.yaml', state=module.monitor.State.FINISH, dry_run=False) def test_ping_monitor_hits_ping_url_for_fail_state(): ping_url = 'https://example.com' - payload = flexmock() + payload = 'data' flexmock(module).should_receive('format_buffered_logs_for_payload').and_return(payload) flexmock(module.requests).should_receive('post').with_args( - '{}/{}'.format(ping_url, 'fail'), data=payload + '{}/{}'.format(ping_url, 'fail'), data=payload.encode('utf') ) module.ping_monitor(ping_url, 'config.yaml', state=module.monitor.State.FAIL, dry_run=False) @@ -88,10 +90,10 @@ def test_ping_monitor_hits_ping_url_for_fail_state(): def test_ping_monitor_with_ping_uuid_hits_corresponding_url(): ping_uuid = 'abcd-efgh-ijkl-mnop' - payload = flexmock() + payload = 'data' flexmock(module).should_receive('format_buffered_logs_for_payload').and_return(payload) flexmock(module.requests).should_receive('post').with_args( - 'https://hc-ping.com/{}'.format(ping_uuid), data=payload + 'https://hc-ping.com/{}'.format(ping_uuid), data=payload.encode('utf-8') ) module.ping_monitor(ping_uuid, 'config.yaml', state=module.monitor.State.FINISH, dry_run=False)