flask-simpleldap
flask-simpleldap copied to clipboard
Error in error handling: TypeError: argument of type 'int' is not iterable
I ran into an error and could not debug because the error handling fails:
File "/usr/local/lib/python3.7/site-packages/flask_simpleldap/__init__.py", line 115, in bind
conn = self.initialize
File "/usr/local/lib/python3.7/site-packages/flask_simpleldap/__init__.py", line 104, in initialize
raise LDAPException(self.error(e.args))
File "/usr/local/lib/python3.7/site-packages/flask_simpleldap/__init__.py", line 276, in error
if 'desc' in e:
TypeError: argument of type 'int' is not iterable
I'm not why this is happening but it's odd.
I've just commented on an upstream issue https://github.com/python-ldap/python-ldap/issues/304 about the various ways python-ldap errors may be raised.
The "'int' is not iterable" error can happen when LDAPError's args represents a non-LDAP error, which is reported with args=(errno, msg), errno being the "int" which is not iterable:
https://github.com/alexferl/flask-simpleldap/blob/c6f63c7f7e40c5e19cfa9cfa2c917dca9efdf46f/flask_simpleldap/init.py#L272-L281
I've encountered this when the connection URL was invalid (in my case a missing port), and running with PYTHON_LDAP_TRACE_LEVEL=2 env var helped track it down.