You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Describe the bug
UnicodeEncode error with webhook sink when finding message contain a non-ASCII character, like an emoji added by cpu_throttling enricher.
To Reproduce
Steps to reproduce the behavior:
Configure a webhook sink
Send Prometheus CPUThrottlingHigh alert
Expected behavior
The message should be encoded in utf-8 so bytes will be provided to requests.post() instead of unicode.
By default, if a python string (unicode) is provided to the http.client lib (used by requests), it will be encoded in latin-1 following RFC 2616.
Traceback
\u001b[32m2023-10-04 15:16:02.999 INFO Loaded k8s pod netbox-prometheus-sd-fcc8c5c95-mv72k for alert CPUThrottlingHigh\u001b[0m
UnicodeEncodeError: 'latin-1' codec can't encode character '\\U0001f4d8' in position 194: Body ('📘') is not valid Latin-1. Use body.encode('utf-8') if you want to send it encoded in UTF-8.\u001b[0m
raise UnicodeEncodeError(
File \"/usr/local/lib/python3.9/http/client.py\
body = _encode(body
File \"/usr/local/lib/python3.9/http/client.py\
self._send_request(method
File \"/usr/local/lib/python3.9/http/client.py\
super(HTTPConnection
File \"/usr/local/lib/python3.9/site-packages/urllib3/connection.py\
conn.request(method
File \"/usr/local/lib/python3.9/site-packages/urllib3/connectionpool.py\
httplib_response = self._make_request(
File \"/usr/local/lib/python3.9/site-packages/urllib3/connectionpool.py\
resp = conn.urlopen(
File \"/usr/local/lib/python3.9/site-packages/requests/adapters.py\
r = adapter.send(request
File \"/usr/local/lib/python3.9/site-packages/requests/sessions.py\
resp = self.send(prep
File \"/usr/local/lib/python3.9/site-packages/requests/sessions.py\
return session.request(method=method
File \"/usr/local/lib/python3.9/site-packages/requests/api.py\
return request('post'
File \"/usr/local/lib/python3.9/site-packages/requests/api.py\
r = requests.post(self.url
File \"/app/src/robusta/core/sinks/webhook/webhook_sink.py\
Traceback (most recent call last):
None
headers:
\u001b[31m2023-10-04 15:16:01.011 ERROR Webhook request error
The text was updated successfully, but these errors were encountered:
Tassatux
changed the title
UnicodeDecode error with webhook sink when message contain a non-ASCII character
UnicodeEncode error with webhook sink when message contain a non-ASCII character
Oct 9, 2023
Would you be interested in contributing a PR to fix? We are understaffed at the moment given world events, so it will take longer than usual for us to fix ourselves. Hope you understand!
Describe the bug
UnicodeEncode error with webhook sink when finding message contain a non-ASCII character, like an emoji added by cpu_throttling enricher.
To Reproduce
Steps to reproduce the behavior:
Expected behavior
The message should be encoded in
utf-8
so bytes will be provided torequests.post()
instead of unicode.By default, if a python string (unicode) is provided to the http.client lib (used by requests), it will be encoded in latin-1 following RFC 2616.
Traceback
The text was updated successfully, but these errors were encountered: