question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

alerts fail when text contains unicode characters

See original GitHub issue

attempting to use a filter on a field containing a unicode/non-ASCII character will cause the following exception in case of an alert:

ERROR:root:Traceback (most recent call last): File “/usr/lib/python2.6/site-packages/elastalert-0.0.57-py2.6.egg/elastalert/elastalert.py”, line 826, in alert return self.send_alert(matches, rule, alert_time=None) File “/usr/lib/python2.6/site-packages/elastalert-0.0.57-py2.6.egg/elastalert/elastalert.py”, line 887, in send_alert alerter.alert(matches) File “/usr/lib/python2.6/site-packages/elastalert-0.0.57-py2.6.egg/elastalert/alerts.py”, line 166, in alert logging.info(str(BasicMatchString(self.rule, match))) File “/usr/lib/python2.6/site-packages/elastalert-0.0.57-py2.6.egg/elastalert/alerts.py”, line 84, in str self._add_match_items() File “/usr/lib/python2.6/site-packages/elastalert-0.0.57-py2.6.egg/elastalert/alerts.py”, line 62, in _add_match_items value_str = str(value) UnicodeEncodeError: ‘ascii’ codec can’t encode character u’\ufeff’ in position 0: ordinal not in range(128)

after replacing the str() call with a unicode() call, the following exception occurs:

ERROR:root:Traceback (most recent call last): File “/usr/lib/python2.6/site-packages/elastalert-0.0.57-py2.6.egg/elastalert/elastalert.py”, line 826, in alert return self.send_alert(matches, rule, alert_time=None) File “/usr/lib/python2.6/site-packages/elastalert-0.0.57-py2.6.egg/elastalert/elastalert.py”, line 887, in send_alert alerter.alert(matches) File “/usr/lib/python2.6/site-packages/elastalert-0.0.57-py2.6.egg/elastalert/alerts.py”, line 166, in alert logging.info(str(BasicMatchString(self.rule, match))) UnicodeEncodeError: ‘ascii’ codec can’t encode character u’\ufeff’ in position 268: ordinal not in range(128)

after replacing the str() call with a unicode() call, the alert appears to work.

Issue Analytics

  • State:closed
  • Created 8 years ago
  • Comments:9 (4 by maintainers)

github_iconTop GitHub Comments

2reactions
Qmandocommented, Aug 25, 2016

If you want newlines, you have to use YAML block syntax

alert_text: |
  Foo bar baz
  This will be on a new line
  blah blah

Whether this technically includes “\r” I think depends on your operating system.

0reactions
ahaiicommented, Nov 23, 2018

@tanxiaolong 您好,麻烦问下您的问题解决了么?我也遇到同样的问题。

Read more comments on GitHub >

github_iconTop Results From Across the Web

How come this alert of a unicode character is not successful?
1 Answer 1 ... \u0041 is the unicode for capital letter A. The interpreter translates it as is, not assuming that it is...
Read more >
Warning about bidirectional Unicode text | GitHub Changelog
A warning is now displayed when a file's contents include bidirectional Unicode text. Such text can be interpreted or compiled differently ...
Read more >
2019 Plot warning: The drawing contains text with unicode ...
"WARNING: The drawing contains text with unicode characters in a referenced font. The PDF may not display correctly on all viewers.
Read more >
MySQL 8.0 Reference Manual :: 10.10.1 Unicode Character Sets
Most Unicode character sets have a general collation (indicated by _general in the name or by the absence of a language specifier), a...
Read more >
Unicode: flag "u" and class \p{...}
Every character in Unicode has a lot of properties. ... let str = "A ბ ㄱ"; alert( str.match(/\p{L}/gu) ); // A,ბ,ㄱ alert( ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found