Edgewall Software
Modify

Opened 4 years ago

Closed 3 years ago

Last modified 3 years ago

#13236 closed defect (fixed)

Message of a TypeError is rendered when CommitTicketReference processor is used in newticket page

Reported by: Jun Omae Owned by: Ryan J Ollos
Priority: normal Milestone: 1.5.3
Component: ticket system Version: 1.0.19
Severity: normal Keywords:
Cc: Branch:
Release Notes:

Fixed TypeError when CommitTicketReference macro or wiki processor is used on the New Ticket form.

API Changes:
Internal Changes:

Description

I encountered TypeError logged from commit_updater.py on production environment.

The exception is raised when CommitTicketReference processor is used in newticket. Message of the exception is rendered as content of the processor.

{{{#!CommitTicketReference repository="reponame" rev=42
}}}
2019-12-20 13:13:25,894 Trac[formatter] DEBUG: Executing Wiki macro CommitTicketReference by provider <tracopt.ticket.commit_updater.CommitTicketReferenceMacro object at 0x7f4e39880b90>
2019-12-20 13:13:25,928 Trac[formatter] ERROR: Processor CommitTicketReference failed for <Resource 'ticket'>:
Traceback (most recent call last):
  File "/venv/trac/1.0.19/lib/python2.5/site-packages/trac/wiki/formatter.py", line 1196, in _exec_processor
    return processor.process(text)
  File "/venv/trac/1.0.19/lib/python2.5/site-packages/trac/wiki/formatter.py", line 364, in process
    text = self.processor(text)
  File "/venv/trac/1.0.19/lib/python2.5/site-packages/trac/wiki/formatter.py", line 348, in _macro_processor
    text, self.args)
  File "/venv/trac/1.0.19/lib/python2.5/site-packages/tracopt/ticket/commit_updater.py", line 315, in expand_macro
    for tkt_id in ticket_re.findall(message)):
  File "/venv/trac/1.0.19/lib/python2.5/site-packages/tracopt/ticket/commit_updater.py", line 315, in <genexpr>
    for tkt_id in ticket_re.findall(message)):
TypeError: int() argument must be a string or a number, not 'NoneType'
192.168.11.19 - - [20/Dec/2019 13:13:25] "POST /1.0-sqlite/newticket HTTP/1.1" 200 -

Quick fix:

  • tracopt/ticket/commit_updater.py

    diff --git a/tracopt/ticket/commit_updater.py b/tracopt/ticket/commit_updater.py
    index 22cf8b1e2..4daeed6e5 100644
    a b from trac.perm import PermissionCache  
    4747from trac.resource import Resource
    4848from trac.ticket import Ticket
    4949from trac.ticket.notification import TicketNotifyEmail
     50from trac.util import as_int
    5051from trac.util.datefmt import datetime_now, utc
    5152from trac.util.text import exception_to_unicode
    5253from trac.util.translation import _, cleandoc_
    class CommitTicketReferenceMacro(WikiMacroBase):  
    310311            message = content
    311312            resource = Resource('repository', reponame)
    312313        if formatter.context.resource.realm == 'ticket':
     314            resource_id = as_int(formatter.context.resource.id, None)
    313315            ticket_re = CommitTicketUpdater.ticket_re
    314             if not any(int(tkt_id) == int(formatter.context.resource.id)
     316            if not any(int(tkt_id) == resource_id
    315317                       for tkt_id in ticket_re.findall(message)):
    316318                return tag.p(_("(The changeset message doesn't reference this "
    317319                               "ticket)"), class_='hint')

Attachments (0)

Change History (8)

comment:1 by Ryan J Ollos, 4 years ago

Milestone: 1.0.20next-stable-1.4.x

Please move back to 1.0.20 if you wish to fix for release 1.0.20 (#13294).

comment:2 by Ryan J Ollos, 4 years ago

Milestone: next-stable-1.4.x1.4.3

comment:3 by Ryan J Ollos, 4 years ago

Owner: set to Ryan J Ollos
Status: newassigned

comment:4 by Ryan J Ollos, 3 years ago

Milestone: 1.4.31.5.3

comment:5 by Ryan J Ollos, 3 years ago

Proposed changes: [a83322d7b7/rjollos.git]

comment:6 by Ryan J Ollos, 3 years ago

Release Notes: modified (diff)

comment:7 by Jun Omae, 3 years ago

Looks good to me. Thanks.

comment:8 by Ryan J Ollos, 3 years ago

Resolution: fixed
Status: assignedclosed

Thanks, committed in r17507.

Version 0, edited 3 years ago by Ryan J Ollos (next)

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'.
to The owner will be changed from Ryan J Ollos to the specified user.

Add Comment


E-mail address and name can be saved in the Preferences .
 
Note: See TracTickets for help on using tickets.