Opened 21 months ago

Last modified 21 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
Cc:

Description

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