Modify ↓
#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 |
||
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 47 47 from trac.resource import Resource 48 48 from trac.ticket import Ticket 49 49 from trac.ticket.notification import TicketNotifyEmail 50 from trac.util import as_int 50 51 from trac.util.datefmt import datetime_now, utc 51 52 from trac.util.text import exception_to_unicode 52 53 from trac.util.translation import _, cleandoc_ … … class CommitTicketReferenceMacro(WikiMacroBase): 310 311 message = content 311 312 resource = Resource('repository', reponame) 312 313 if formatter.context.resource.realm == 'ticket': 314 resource_id = as_int(formatter.context.resource.id, None) 313 315 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 315 317 for tkt_id in ticket_re.findall(message)): 316 318 return tag.p(_("(The changeset message doesn't reference this " 317 319 "ticket)"), class_='hint')
Attachments (0)
Change History (8)
comment:1 by , 5 years ago
Milestone: | 1.0.20 → next-stable-1.4.x |
---|
comment:2 by , 4 years ago
Milestone: | next-stable-1.4.x → 1.4.3 |
---|
comment:3 by , 4 years ago
Owner: | set to |
---|---|
Status: | new → assigned |
comment:4 by , 4 years ago
Milestone: | 1.4.3 → 1.5.3 |
---|
comment:6 by , 4 years ago
Release Notes: | modified (diff) |
---|
comment:8 by , 4 years ago
Resolution: | → fixed |
---|---|
Status: | assigned → closed |
Thanks, committed in r17508.
Note:
See TracTickets
for help on using tickets.
Please move back to 1.0.20 if you wish to fix for release 1.0.20 (#13294).