Modify

Opened 5 years ago

Closed 5 years ago

#13728 closed defect (fixed)

save_changes() got an unexpected keyword argument 'cnum' in TracBacksPlugin on Trac 1.4

Reported by: Justin Ludwig Owned by: Ryan J Ollos
Priority: normal Component: TracBacksPlugin
Severity: normal Keywords:
Cc: Trac Release: 1.4

Description

With Trac 1.4, getting a TypeError: save_changes() got an unexpected keyword argument 'cnum' error when adding a comment that references another ticket.

Repo Steps

On Trac 1.4 with TracBacksPlugin installed:

  1. navigate to ticket 1
  2. enter comment this is related to #2 in "Add Comment" textarea
  3. click "Submit changes" button

Expected

Comment added to ticket 1 with no errors; and tracbacks comment added to ticket 2.

Actual

Comment added to ticket 1, but resulting webpage displays 500 error, and following sent to trac log:

2020-01-09 21:21:55,671 Trac[main] ERROR: [192.0.1.1] Internal Server Error: <RequestWithSession "POST '/ticket/1'">, referrer 'https://trac.example.com/test/ticket/1'
Traceback (most recent call last):
  File "/usr/local/lib/python2.7/dist-packages/trac/web/main.py", line 639, in dispatch_request
    dispatcher.dispatch(req)
  File "/usr/local/lib/python2.7/dist-packages/trac/web/main.py", line 250, in dispatch
    resp = chosen_handler.process_request(req)
  File "/usr/local/lib/python2.7/dist-packages/trac/ticket/web_ui.py", line 183, in process_request
    return self._process_ticket_request(req)
  File "/usr/local/lib/python2.7/dist-packages/trac/ticket/web_ui.py", line 689, in _process_ticket_request
    self._do_save(req, ticket, action)
  File "/usr/local/lib/python2.7/dist-packages/trac/ticket/web_ui.py", line 1401, in _do_save
    replyto=req.args.get('replyto'))
  File "/usr/local/lib/python2.7/dist-packages/trac/ticket/model.py", line 430, in save_changes
    listener.ticket_changed(self, comment, author, old_values)
  File "/usr/local/lib/python2.7/dist-packages/Tracbacks-0.2.dev0-py2.7.egg/tracbacks/tracbacks.py", line 87, in ticket_changed
    t.save_changes(author, tracback, cnum=cnum_thischange)
TypeError: save_changes() got an unexpected keyword argument 'cnum'

Also, trackbacks comment not added to ticket 2, and ticket-update email notifications not sent.

Workaround

Editing the TracBacksPlugin tracbacks/tracbacks.py file to remove the cnum arg from the save_changes() call seems to fix the issue.

Attachments (0)

Change History (3)

comment:1 Changed 5 years ago by Justin Ludwig

Specifically, this change fixes the issue for me, with no other ill effects I've found so far:

Index: tracbacks/tracbacks.py
===================================================================
--- tracbacks/tracbacks.py	(revision 17646)
+++ tracbacks/tracbacks.py	(working copy)
@@ -68,23 +68,7 @@
                     continue
                     
                 tracback = self.create_tracbacks(ticket, t, comment)
-                
-                # cnum is stored in the ticket_change table as an string
-                # identifying the comment number, and if applicable,
-                # the replyto comment number. If comment 8 is a reply to
-                # comment 4, the string will be '4.8'. The index is used
-                # by the TicketChangePlugin to identify the comment being
-                # edited, so we make sure to add it here.
-                change_log = [i for i in t.get_changelog()
-                              if i[2] == "comment"]
-                if change_log != []:
-                    lastchange = change_log[-1]
-                    cnum_lastchange = lastchange[3].rsplit('.', 1)
-                    cnum_lastcomment = int(cnum_lastchange[-1])
-                    cnum_thischange = str(cnum_lastcomment + 1)
-                else:
-                    cnum_thischange = "1"
-                t.save_changes(author, tracback, cnum=cnum_thischange)
+                t.save_changes(author, tracback)
                     
 
     def ticket_deleted(self, ticket):

comment:2 Changed 5 years ago by Ryan J Ollos

Owner: changed from ejucovy to Ryan J Ollos
Status: newaccepted

comment:3 Changed 5 years ago by Ryan J Ollos

Resolution: fixed
Status: acceptedclosed

In 17657:

TracBacks 0.2dev: Make compatible with Trac 1.4+

Fixes #13728.

Modify Ticket

Change Properties
Set your email in Preferences
Action
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.