#453 Recovered: many error messages give no useful information
Closed: Fixed by t0xic0der. Opened by t0xic0der.

Looking at the httpd error_log I kept seeing this message:

ERROR: unsupported format character ',' (0x2c) at index 14

I had no idea what was causing it. Turns out there was a mistake in the LDAP user dn template (a user provided value). But figuring this out was painful and time consuming. I had to add strack trace printing to util.log.Log.error() at which point I discovered the error was coming from infoldap.get_user_attrs()

    def get_user_attrs(self, user):
        try:
            conn = self._ldap_bind()
            dn = self.user_dn_tmpl % {'username': user}
            return self.get_user_data_from_conn(conn, dn)
        except Exception, e:  # pylint: disable=broad-except
            self.error(e)
            return {}

It logs the error but without any context whatsoever. At a minimum it should include in the error message what it was trying to do, including the dn would have been really helpful as well. Then it would have been obvious what was going wrong instead of some cryptic message about an illegal format character at position 14.

There are many places in the code which simply log the error message without any context. All of these need fixing, not just this one example.

FWIW this is the code I added to log.error() function to get the stacktrace

import cStringIO
import traceback
    def error(self, fact):
        cherrypy.log.error('ERROR: %s' % fact)
        f = cStringIO.StringIO()
        traceback.print_stack(file=f)
        stack_trace = f.getvalue()
        f.close()
        cherrypy.log.error(stack_trace)

This might be a useful addition if the stacktrace logging were controlled by a config value.


This issue ticket was originally removed from the tracker as it clashed with the pull request.
See upstream ticket for migration details.


Metadata Update from @t0xic0der:
- Issue close_status updated to: Fixed
- Issue status updated to: Closed (was: Open)

Metadata