Uninett / Howitz

1 stars 3 forks source link

Bug: current_app.updater can be None when we try to update #133

Closed hmpf closed 2 weeks ago

hmpf commented 2 weeks ago

I was testing a branch (bulk-select-with-row-highlight) and got this when restarting the server (flask -A howitz run):

ERROR howitz in handle_generic_exception: Exception in /refresh_events: 'NoneType' object ha
s no attribute 'get_event_update': 
Traceback (most recent call last): 
 File "/../.virtualenvs/howitz/lib/python3.10/site-packages/flask/app.py", line 1484, 
in full_dispatch_request 
   rv = self.dispatch_request() 
 File "/../.virtualenvs/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 "/HOME/../howitz/src/howitz/endpoints.py", line 366, in refresh_event
s 
   removed_events, modified_events, added_events = refresh_current_events() 
 File "/HOME/../howitz/src/howitz/endpoints.py", line 156, in refresh_curre
nt_events 
   event_ids = update_events() 
 File "/HOME/../howitz/src/howitz/endpoints.py", line 140, in update_events 
   updated = current_app.updater.get_event_update() 
AttributeError: 'NoneType' object has no attribute 'get_event_update' 

I guess it is caused by trying to update before we have logged in.

Might even be fixed on main.

hmpf commented 2 weeks ago

Not fixed on main, here's what I think happens.

You have howitz open in the browser while testing and turn off/on the actual server. The browser still has the htmx triggering a refresh but you are not necessarily logged in, so there is no UpdateHandler yet.

The exception can be removed by only refreshing when we know we have an updatehandler.