traceback caused by difflimit = 0

Bug #250901 reported by Steve Langasek
6
Affects Status Importance Assigned to Milestone
bzr email commit hook
Fix Released
High
James Teh

Bug Description

Trying to use bzr-email as a post commit hook, I get the following traceback:

[...]
Committed revision 700.
bzr: ERROR: exceptions.AssertionError:

Traceback (most recent call last):
  File "/usr/lib/python2.5/site-packages/bzrlib/commands.py", line 846, in run_bzr_catch_errors
    return run_bzr(argv)
  File "/usr/lib/python2.5/site-packages/bzrlib/commands.py", line 797, in run_bzr
    ret = run(*run_argv)
  File "/usr/lib/python2.5/site-packages/bzrlib/commands.py", line 499, in run_argv_aliases
    return self.run(**all_cmd_args)
  File "/usr/lib/python2.5/site-packages/bzrlib/builtins.py", line 2364, in run
    author=author)
  File "/usr/lib/python2.5/site-packages/bzrlib/decorators.py", line 165, in write_locked
    return unbound(self, *args, **kwargs)
  File "/usr/lib/python2.5/site-packages/bzrlib/workingtree_4.py", line 240, in commit
    result = WorkingTree3.commit(self, message, revprops, *args, **kwargs)
  File "/usr/lib/python2.5/site-packages/bzrlib/decorators.py", line 165, in write_locked
    return unbound(self, *args, **kwargs)
  File "/usr/lib/python2.5/site-packages/bzrlib/mutabletree.py", line 197, in commit
    revprops=revprops, *args, **kwargs)
  File "/usr/lib/python2.5/site-packages/bzrlib/commit.py", line 402, in commit
    self._process_post_hooks(old_revno, new_revno)
  File "/usr/lib/python2.5/site-packages/bzrlib/commit.py", line 521, in _process_post_hooks
    self._process_hooks("post_commit", old_revno, new_revno)
  File "/usr/lib/python2.5/site-packages/bzrlib/commit.py", line 560, in _process_hooks
    self.rev_id)
  File "/usr/lib/python2.5/site-packages/bzrlib/plugins/email/__init__.py", line 52, in branch_commit_hook
    local_branch=local).send_maybe()
  File "/usr/lib/python2.5/site-packages/bzrlib/plugins/email/emailer.py", line 229, in send_maybe
    self.send()
  File "/usr/lib/python2.5/site-packages/bzrlib/plugins/email/emailer.py", line 173, in send
    self._send_using_smtplib()
  File "/usr/lib/python2.5/site-packages/bzrlib/plugins/email/emailer.py", line 222, in _send_using_smtplib
    self.diff_filename())
  File "/usr/lib/python2.5/site-packages/bzrlib/plugins/email/smtp_connection.py", line 213, in send_text_and_attachment_email
    assert isinstance(attachment_text, str)
AssertionError

bzr 1.5 on python 2.5.2 (linux2)
arguments: ['/usr/bin/bzr', 'commit', '-m', 'drop some stray files that crept into the debdiff, having been removed upstream\nin a previous revision']
encoding: 'UTF-8', fsenc: 'UTF-8', lang: 'en_US.UTF-8'
plugins:
  builddeb /usr/lib/python2.5/site-packages/bzrlib/plugins/builddeb [0.95.0dev0]
  bzrtools /usr/lib/python2.5/site-packages/bzrlib/plugins/bzrtools [1.5.0]
  cvsps_import /usr/lib/python2.5/site-packages/bzrlib/plugins/cvsps_import [unknown]
  email /usr/lib/python2.5/site-packages/bzrlib/plugins/email [unknown]
  launchpad /usr/lib/python2.5/site-packages/bzrlib/plugins/launchpad [unknown]
  svn /usr/lib/python2.5/site-packages/bzrlib/plugins/svn [0.4.10]
*** Bazaar has encountered an internal error.
    Please report a bug at https://bugs.launchpad.net/bzr/+filebug
    including this traceback, and a description of what you
    were doing when the error occurred.

My locations.conf is as follows:

[/home/devel/pam/pam.deb]
email = Steve Langasek <email address hidden>
post_commit_to = <email address hidden>
post_commit_difflimit = 0
post_commit_mailer = smtplib
smtp_server=localhost

I was also getting tracebacks before I tried to configure it to use smtplib, I think the traceback was slightly different in that case.

Related branches

Revision history for this message
Steve Langasek (vorlon) wrote :

As requested by James Westby, I've set PDB_BZR=1 in the env and committed again, to check the type of attachment_text:

(Pdb) type(attachment_text)
<type 'NoneType'>

Could it be that I've misunderstood how 'post_commit_difflimit = 0' is supposed to work?

Revision history for this message
James Westby (james-w) wrote :

If difflimit == 0 then it returns None, rather than the "diff too large"
string returned if the value is > 0 and the diff is larger than that. Either
a string should be returned, or the None value should be handled.

However, Steve said that he thought 0 would mean no-limit. I think
either that, or using -1 to mean this would be a good idea.

Thanks,

James

Revision history for this message
Robert Collins (lifeless) wrote : Re: [Bug 250901] Re: traceback caused by difflimit = 0

On Tue, 2008-07-22 at 18:35 +0000, James Westby wrote:
> If difflimit == 0 then it returns None, rather than the "diff too large"
> string returned if the value is > 0 and the diff is larger than that. Either
> a string should be returned, or the None value should be handled.
>
> However, Steve said that he thought 0 would mean no-limit. I think
> either that, or using -1 to mean this would be a good idea.

This is a regression - the docs say use 0 to disable the feature.

-Rob
--
GPG key available at: <http://www.robertcollins.net/keys.txt>.

Revision history for this message
Steve Langasek (vorlon) wrote :

On Wed, Jul 23, 2008 at 09:17:01PM -0000, Robert Collins wrote:
> On Tue, 2008-07-22 at 18:35 +0000, James Westby wrote:
> > If difflimit == 0 then it returns None, rather than the "diff too large"
> > string returned if the value is > 0 and the diff is larger than that. Either
> > a string should be returned, or the None value should be handled.

> > However, Steve said that he thought 0 would mean no-limit. I think
> > either that, or using -1 to mean this would be a good idea.

> This is a regression - the docs say use 0 to disable the feature.

FWIW, when I read the docs I understood "the feature" as "the feature of
limiting message size" rather than "the feature of sending mail"; it seemed
obvious to me that there were easier ways to disable sending mail, like by
not configuring a to: address.

So it would be nice if the docs could be clarified too.

--
Steve Langasek Give me a lever long enough and a Free OS
Debian Developer to set it on, and I can move the world.
Ubuntu Developer http://www.debian.org/
<email address hidden> <email address hidden>

Revision history for this message
Robert Collins (lifeless) wrote :

On Wed, 2008-07-23 at 21:45 +0000, Steve Langasek wrote:
>
>
> FWIW, when I read the docs I understood "the feature" as "the feature
> of
> limiting message size" rather than "the feature of sending mail"; it
> seemed
> obvious to me that there were easier ways to disable sending mail,
> like by
> not configuring a to: address.
>
> So it would be nice if the docs could be clarified too.

0 is meant to disable "the feature of limiting message size".

Ack on clarification opportunity though.

-Rob
--
GPG key available at: <http://www.robertcollins.net/keys.txt>.

Revision history for this message
Eric Ferraiuolo (eferraiuolo) wrote :

I'm having a similar issue, and like the above suggestion, I've set the limit to -1.

File "/usr/lib/python2.5/site-packages/bzrlib/plugins/email/__init__.py", line 98, in branch_post_change_hook
    params.branch.get_config(), local_branch=None, op='change').send_maybe()
  File "/usr/lib/python2.5/site-packages/bzrlib/plugins/email/emailer.py", line 248, in send_maybe
    self.send()
  File "/usr/lib/python2.5/site-packages/bzrlib/plugins/email/emailer.py", line 185, in send
    self._send_using_process()
  File "/usr/lib/python2.5/site-packages/bzrlib/plugins/email/emailer.py", line 198, in _send_using_process
    message = self.body().encode('utf8') + self.get_diff()
TypeError: cannot concatenate 'str' and 'NoneType' objects

Revision history for this message
John A Meinel (jameinel) wrote :

Just mentioning that we just encountered this. And we actually wanted the ability to disable showing the diff. Mostly because the people here want to see when trunk changes, but they don't care about the specifics of that change.

Changed in bzr-email:
importance: Undecided → High
status: New → Confirmed
Jelmer Vernooij (jelmer)
Changed in bzr-email:
status: Confirmed → Fix Committed
assignee: nobody → James Teh (jteh)
Jelmer Vernooij (jelmer)
Changed in bzr-email:
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.