#39 many error messages give no useful information
Closed: Fixed None Opened 9 years ago by jdennis.

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.


FWIW, this is value that was causing the problem:

uid=%(username),cn=users,cn=accounts,dc=idm,dc=lab,dc=bos,dc=redhat,dc=com

The problem was %(username) should have been followed by an s, an easy mistake to make. FWIW I could find no documentation for what the user dn template should be. I had to search the code to find out it's doing a dict substitution using the key 'username'. The format of the user dn template really ought to be documented somewhere, but there are othter tickets open about missing doc.

_comment0: FWIW, this is value that was causing the problem:

{{{
cn=%(username),cn=accounts,dc=idm,dc=lab,dc=bos,dc=redhat,dc=com
}}}

The problem was %(username) should have been followed by an s, an easy mistake to make. FWIW I could find no documentation for what the user dn template should be. I had to search the code to find out it's doing a dict substitution using the key 'username'. The format of the user dn template really ought to be documented somewhere, but there are othter tickets open about missing doc. => 1420823316220301

Fields changed

milestone: => 1.0 m1
owner: simo => npmccallum
status: new => assigned

Fields changed

milestone: 1.0 m1 => 1.0 m2

Fields changed

milestone: 1.0 m2 => 1.0 m3
patch_available: => 0

Fields changed

owner: npmccallum =>

Fields changed

status: assigned => new

Fields changed

milestone: 1.0 m3 => 1.0

Fields changed

milestone: 1.0 m4 => Backlog

Fields changed

milestone: Backlog => 1.1

Fields changed

milestone: 1.1 => 1.2

Fields changed

design_link: =>
owner: => rcritten
rhbz: =>
status: new => accepted

master: 7ba361e

resolution: => fixed
status: accepted => closed

Metadata Update from @rcritten:
- Issue assigned to rcritten
- Issue set to the milestone: 1.2

7 years ago

Login to comment on this ticket.

Metadata