Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

unsupported operand type(s) for +=: 'int' and 'NoneType' #2759

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

gminog
Copy link

@gminog gminog commented Apr 24, 2020

Under certain circumstances, the event argument passed in the functions 'append' or 'append_middle' of the RuleTypes class can be None.
The aforementioned functions now perform a None check so that errors such as the below are avoided:

ERROR:root:Traceback (most recent call last):
  File "/usr/lib/python3.6/site-packages/elastalert/elastalert.py", line 1269, in handle_rule_execution
    num_matches = self.run_rule(rule, endtime, rule.get('initial_starttime'))
  File "/usr/lib/python3.6/site-packages/elastalert/elastalert.py", line 897, in run_rule
    self.run_query(rule, tmp_endtime, endtime)
  File "/usr/lib/python3.6/site-packages/elastalert/elastalert.py", line 649, in run_query
    rule_inst.add_aggregation_data(data)
  File "/usr/lib/python3.6/site-packages/elastalert/ruletypes.py", line 1144, in add_aggregation_data
    self.handle_event(event, agg_value, 'all')
  File "/usr/lib/python3.6/site-packages/elastalert/ruletypes.py", line 448, in handle_event
    self.cur_windows[qk].append((event, count))
  File "/usr/lib/python3.6/site-packages/elastalert/ruletypes.py", line 321, in append
    self.running_count += event[1]
TypeError: unsupported operand type(s) for +=: 'int' and 'NoneType'

ERROR:root:Uncaught exception running rule /opt/elastalert/rules/SpikeRule12: unsupported operand type(s) for +=: 'int' and 'NoneType'

@Qmando FYI

…'append_middle' take into account the scenario whereby an event is None
…'append_middle' take into account the scenario whereby an event is None
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants