Opened 15 months ago

Last modified 15 months ago

#3651 new defect

MailNotifier exception in _defaultMessageIntro() if build result is RETRY

Reported by: dcoshea Owned by:
Priority: major Milestone: undecided
Version: 0.8.12 Keywords: mail


As noted in ticket #3650, when the MailNotifier mode includes change, if the build status changes to RETRY, the MailNotifier will attempt to send an email.

In 0.8.12, this causes an exception, which results in no email being sent:

2016-12-01 15:43:04+1030 [Broker,8,]  step 'Build' complete: retry
2016-12-01 15:43:04+1030 [Broker,8,]  <Build [...]>: build finished
2016-12-01 15:43:04+1030 [Broker,8,] Exception caught notifying <buildbot.status.mail.MailNotifier instance at 0x21fa4758> of buildFinished event
2016-12-01 15:43:04+1030 [Broker,8,] Unhandled Error
        Traceback (most recent call last):
          File "[...]/src/buildbot/master/buildbot/status/", line 320, in buildFinished
          File "[...]/lib/python2.6/site-packages/twisted/internet/", line 380, in callback
          File "[...]/lib/python2.6/site-packages/twisted/internet/", line 488, in _startRunCallbacks
          File "[...]/lib/python2.6/site-packages/twisted/internet/", line 575, in _runCallbacks
            current.result = callback(current.result, *args, **kw)
        --- <exception caught here> ---
          File "[...]/src/buildbot/master/buildbot/status/", line 597, in _buildFinished
            w.buildFinished(name, s, results)
          File "[...]/src/buildbot/master/buildbot/status/", line 537, in buildFinished
            return self.buildMessage(name, [build], results)
          File "[...]/src/buildbot/master/buildbot/status/", line 735, in buildMessage
            build=build, results=build.results)
          File "[...]/src/buildbot/master/buildbot/status/", line 716, in buildMessageDict
          File "[...]/src/buildbot/master/buildbot/status/", line 190, in defaultMessage
            text = _defaultMessageIntro(mode, results, build)
          File "[...]/src/buildbot/master/buildbot/status/", line 108, in _defaultMessageIntro
            return text
        exceptions.UnboundLocalError: local variable 'text' referenced before assignment

The exception occurs because _defaultMessageIntro() doesn't have a case for RETRY, and hence fails to assign to the text variable if that is the build's result. As noted in ticket #3650, has no references to the RETRY result at all.

From a review of the 0.9.1 source, it seems that it would not be affected by this bug since although and still don't have any explicit handling for the RETRY result, getDetectedStatus(), which looks like it has taken over part of the role of _defaultMessageIntro(), has an else: case that would catch RETRY results.

Change History (1)

comment:1 Changed 15 months ago by dcoshea

Note that this is a regression compared to earlier versions of Buildbot. I didn't notice this issue prior to upgrading to 0.8.12. When I looked at the source for 0.8.6, for example, this logic was in defaultMessage(), and in the case of RETRY, it would simply omit the first line of the email like "The Buildbot has detected a result build", but still send the email.

Note: See TracTickets for help on using tickets.