onaio/onadata

TypeError: '>=' not supported between instances of 'NoneType' and 'int'

ukanga opened this issue · 0 comments

Environmental Information

  • Onadata version: 3.17.2 or newer

Problem description

An exception is thrown when the attempts value from the cache is cleared. This could happen if the value is removed between lines 307 and 311. A further check is necessary before comparison on line 312.

TypeError: '>=' not supported between instances of 'NoneType' and 'int'
(9 additional frame(s) were not displayed)
...
  File "onadata/libs/authentication.py", line 113, in authenticate
    attempts = login_attempts(request)
  File "onadata/libs/authentication.py", line 312, in login_attempts
    if attempts >= getattr(settings, "MAX_LOGIN_ATTEMPTS", 10):

Expected behaviour

No exception thrown.

Steps to reproduce the behavior

Difficult to replicate unless in debugging or with mock testing.

Additional Information