Uninett / zinolib

Python library for zino
Apache License 2.0
1 stars 3 forks source link

Bug: `create_event_id` gets unexpected output from `get_attrlist()` #35

Closed hmpf closed 7 months ago

hmpf commented 7 months ago
Traceback (most recent call last):                                                 
  File "/VENV/howitz/lib/python3.10/site-packages/flask/app.py", line 2213, in __call__
    return self.wsgi_app(environ, start_response)                                  
  File "/VENV/howitz/lib/python3.10/site-packages/flask/app.py", line 2193, in wsgi_app
    response = self.handle_exception(e)                                            
  File "/VENV/howitz/lib/python3.10/site-packages/flask/app.py", line 2190, in wsgi_app
    response = self.full_dispatch_request()                                        
  File "/VENV/howitz/lib/python3.10/site-packages/flask/app.py", line 1486, in full_dispatch+++_request
    rv = self.handle_user_exception(e)                                             
  File "/VENV/howitz/lib/python3.10/site-packages/flask/app.py", line 1484, in full_dispatch+++_request
    rv = self.dispatch_request()                                                   
  File "/VENV/howitz/lib/python3.10/site-packages/flask/app.py", line 1469, in dispatch_requ+++est
    return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)       
  File "/../howitz/src/howitz/endpoints.py", line 328, in expand_event_row         
    event_attr, event_logs, event_history, event_msgs = get_event_details(event_id)
  File "/../howitz/src/howitz/endpoints.py", line 213, in get_event_details        
    event_attr = vars(current_app.event_manager.create_event_from_id(int(id)))  
  File "/../zinolib/src/zinolib/controllers/zino1.py", line 463, in create_event_from_id
    attrdict = self._event_adapter.attrlist_to_attrdict(attrlist)                  
  File "/../zinolib/src/zinolib/controllers/zino1.py", line 260, in attrlist_to_attrdict
    k, v = item.split(":", 1)                                                      
ValueError: not enough values to unpack (expected 2, got 1)            

We need to decide what to do with this.

We should probably also have a way to dump the raw received data from the server so that we can see what's going on. Or set up an error-logger like Sentry.

hmpf commented 7 months ago

After improving logging of attrlist_to_attrdict() it turns out the "attrlist" is a list of strings of integers (multiple event ids) instead of a list of strings containing the body of a single event.

Two tracebacks, one error.

2023-11-29 13:07:48,633 ERROR zinolib.controllers.zino1 /../zinolib/src/zinolib/utils.py:78:: "attrlist_to_attrdict" failed with: args=(<class 'zinolib.controllers.zino1.EventAdapter'>, ['77049', '138951', '140215', '140216', '140217', '157618', '157776', '157777', '157878', '159410', '159415', '159440', '159643', '161454', '162170', '162172', '162173', '162538', '162541', '162590', '162686', '162707', '163022', '163036', '163057', '163076', '163171', '163173', '163176', '163177', '163190', '163191', '163192', '163193', '163200', '163201', '163202', '163203', '163204', '163205']) kwargs={}
not enough values to unpack (expected 2, got 1)
Traceback (most recent call last):
  File "/../zinolib/src/zinolib/utils.py", line 73, in wrapper
    result = function(*args, **kwargs)
  File "/../zinolib/src/zinolib/controllers/zino1.py", line 262, in attrlist_to_attrdict
    k, v = item.split(":", 1)
ValueError: not enough values to unpack (expected 2, got 1)
2023-11-29 13:07:48,633 ERROR howitz /VENVS/howitz/lib/python3.10/site-packages/flask/app.py:1414:: Exception on /events/157777/expand_row [GET]
Traceback (most recent call last):
  File "/VENVS/howitz/lib/python3.10/site-packages/flask/app.py", line 2190, in wsgi_app
    response = self.full_dispatch_request()
  File "/VENVS/howitz/lib/python3.10/site-packages/flask/app.py", line 1486, in full_dispatch_request
    rv = self.handle_user_exception(e)
  File "/VENVS/howitz/lib/python3.10/site-packages/flask/app.py", line 1484, in full_dispatch_request
    rv = self.dispatch_request()
  File "/VENVS/howitz/lib/python3.10/site-packages/flask/app.py", line 1469, in dispatch_request
    return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)
  File "/../howitz/src/howitz/endpoints.py", line 291, in expand_event_row
    event_attr, event_logs, event_history, event_msgs = get_event_details(event_id)
  File "/../howitz/src/howitz/endpoints.py", line 196, in get_event_details
    event_attr = vars(current_app.event_manager.create_event_from_id(int(id)))
  File "/../zinolib/src/zinolib/controllers/zino1.py", line 467, in create_event_from_id
    attrdict = self._event_adapter.attrlist_to_attrdict(attrlist)
  File "/../zinolib/src/zinolib/utils.py", line 73, in wrapper
    result = function(*args, **kwargs)
  File "/../zinolib/src/zinolib/controllers/zino1.py", line 262, in attrlist_to_attrdict
    k, v = item.split(":", 1)
ValueError: not enough values to unpack (expected 2, got 1)
hmpf commented 7 months ago

It basically looks like the Zino 1 server sometimes replies to a "getattrs" command with the result of "caseids". We can discover this, but there's nothing zinolib can really do to fix it.