Opened 12 years ago

Closed 11 years ago

Last modified 11 years ago

#9743 closed defect (fixed)

Exception when latest change on referenced ticket is not a comment

Reported by: ejucovy Owned by: Ryan J Ollos
Priority: normal Component: TracBacksPlugin
Severity: normal Keywords:
Cc: Trac Release: 0.12

Description (last modified by Ryan J Ollos)

If you reference a ticket whose latest modification is not a comment, the plugin will fail with an error. To reproduce:

  1. Create a ticket
  2. Comment on that ticket
  3. Change the ticket's priority from major to minor
  4. Create a second ticket
  5. Comment on the second ticket with a reference to the first ticket

The plugin will fail with a ValueError, because it assumes that the latest changelog entry in t.get_changelog() will always be a comment.

When running against trac trunk, the plugin raises an exception:

File "ve/src/trac/trac/ticket/", line 360, in save_changes
  listener.ticket_changed(self, comment, author, old_values)
File "ve/src/tracbacksplugin/tracbacks/", line 103, in ticket_changed
  cnum_lastcomment = int(cnum_lastchange[-1])
ValueError: invalid literal for int() with base 10: 'minor'

I haven't tested against earlier versions of Trac to see if it's a new issue. It does seem to be related to #9008 -- and a commenter (comment:1:ticket:9008) posted a traceback there, against trac 0.12.2, which is functionally identical to the traceback I'm seeing.

The following patch fixes the problem by filtering the referenced-ticket's changelog to only include comments:

  • tracbacks/

    9595                # by the TicketChangePlugin to identify the comment being
    9696                # edited, so we make sure to add it here.
    9797                cnum_thischange = 1               
    98                 change_log = t.get_changelog()
     98                change_log = [i for i in t.get_changelog() if i[2] == "comment"]
    9999                if change_log != []:
    100100                    lastchange = change_log[-1]
    101101                    cnum_lastchange = lastchange[3].rsplit('.', 1)

Attachments (0)

Change History (2)

comment:1 Changed 11 years ago by ejucovy

Resolution: fixed
Status: newclosed

(In [12080]) ticket.get_changelog() returns entries that aren't comments (as well as entries that are comments) -- so, if the latest modification on the ticket does not have a comment, tracbacks will cause an internal error by assuming an incorrect data structure. this commit fixes the problem by filtering out all changelog entries that are not comments. (fixes #9743)

comment:2 Changed 11 years ago by Ryan J Ollos

Description: modified (diff)

Modify Ticket

Change Properties
Set your email in Preferences
as closed The owner will remain Ryan J Ollos.
The resolution will be deleted. Next status will be 'reopened'.

Add Comment

E-mail address and name can be saved in the Preferences.

Note: See TracTickets for help on using tickets.