Ticket #416 (closed fixme: worksforme)

Opened 2 years ago

Last modified 9 months ago

Trac: diff view on ticket text causes internal error

Reported by: ichthyo Owned by:
Priority: nice Milestone:
Component: infrastructure Keywords:
Cc: Blocked By:
Blocking:

Description (last modified by ichthyo) (diff)

Following the "diff.." link on description changes in the ticket changelog causes a python stacktrace. From a quick investigation it looks as if the mastertickets plugin is the culprit. Development on this plugin seems to have stalled since a year, so, if this gets a problem, we should fix it ourselves...

Python Traceback
Most recent call last:

  • File "/usr/lib/python2.5/site-packages/trac/web/main.py", line 423, in _dispatch_request
        418. try:
        419. if not env and env_error:
        420. raise HTTPInternalError(env_error)
        421. try:
        422. dispatcher = RequestDispatcher(env)
        423. dispatcher.dispatch(req)
        424. except RequestDone:
        425. pass
        426. resp = req._response or []
        427.  
        428. except HTTPException, e:
       Local variables:
       Name	Value
       after 	[u' except RequestDone:', u' pass', u' resp = ...
       before 	[u' try:', u' if not env and env_error:', u' raise ...
       dispatcher 	<trac.web.main.RequestDispatcher object at 0x1b12790>
       e 	KeyError('fields',)
       env 	<trac.env.Environment object at 0x1657390>
       env_error 	None
       exc_info 	(<type 'exceptions.KeyError'>, KeyError('fields',), <traceback object at ...
       filename 	'/usr/lib/python2.5/site-packages/trac/web/main.py'
       frames 	[{'function': '_dispatch_request', 'lines_before': [u' try:', u' ...
       has_admin 	True
       line 	u' dispatcher.dispatch(req)'
       lineno 	422
       message 	u"KeyError: 'fields'"
       req 	<Request "GET u'/ticket/414'">
       resp 	[]
       tb 	<traceback object at 0x1ed7f38>
       tb_hide 	None
       traceback 	'Traceback (most recent call last):\n File   
    
  • File "/usr/lib/python2.5/site-packages/trac/web/main.py", line 209, in dispatch
     204. if req.session:
     205. req.session.save()
     206. req.display(template, content_type or 'text/html')
     207. else: # Genshi
     208. template, data, content_type = \
     209. self._post_process_request(req, *resp)
     210. if 'hdfdump' in req.args:
     211. req.perm.require('TRAC_ADMIN')
     212. # debugging helper - no need to render first
     213. from pprint import pprint
     214. out = StringIO()
    Local variables:
    Name	Value
    chosen_handler 	<trac.ticket.web_ui.TicketModule object at 0x1b12850>
    chrome 	<trac.web.chrome.Chrome object at 0x19c3410>
    e 	TypeError("'NoneType' object is unsubscriptable",)
    err 	(<type 'exceptions.KeyError'>, KeyError('fields',), <traceback object at ...
    handler 	<trac.ticket.web_ui.TicketModule object at 0x1b12850>
    req 	<Request "GET u'/ticket/414'">
    resp 	('diff_view.html', {'comment': None, 'longcol': '', 'new_version': 1, ...
    self 	<trac.web.main.RequestDispatcher object at 0x1b12790>
    
  • File "/usr/lib/python2.5/site-packages/trac/web/main.py", line 299, in _post_process_request
     294. # Trac 0.10, only filters with same arity gets passed real values.
     295. # Errors will call all filters with None arguments,
     296. # and results will not be not saved.
     297. extra_arg_count = arity(f.post_process_request) - 2
     298. if extra_arg_count == nbargs:
     299. resp = f.post_process_request(req, *resp)
     300. elif nbargs == 0:
     301. f.post_process_request(req, *(None,)*extra_arg_count)
     302. return resp
     303.  
     304.  
    Local variables:
    Name	Value
    args 	('diff_view.html', {'comment': None, 'longcol': '', 'new_version': 1, ...
    extra_arg_count 	3
    f 	<mastertickets.web_ui.MasterTicketsModule object at 0x1b12dd0>
    nbargs 	3
    req 	<Request "GET u'/ticket/414'">
    resp 	('diff_view.html', {'comment': None, 'longcol': '', 'new_version': 1, ...
    self 	<trac.web.main.RequestDispatcher object at 0x1b12790>
    
  • File "/var/local/trac/trac-env/plugins/TracMasterTickets-2.1.3-py2.5.egg/mastertickets/web_ui.py", line 64, in post_process_request
       Local variables:
       Name	Value
       change 	{'diffs': [], 'old': {'path': 'Ticket #414', 'href': ...
       content_type 	None
       data 	{'comment': None, 'longcol': '', 'new_version': 1, 'num_changes': 1, ...
       links 	<mastertickets.model.TicketLinks #414 blocking=[77] blocked_by=[]>
       req 	<Request "GET u'/ticket/414'">
       self 	<mastertickets.web_ui.MasterTicketsModule object at 0x1b12dd0>
       template 	'diff_view.html'
       tkt 	<trac.ticket.model.Ticket object at 0x1e0b390>
    

Change History

comment:1 Changed 2 years ago by ichthyo

  • Description modified (diff)

Just looking at mastertickets/web_ui.py, there is a blatant error. Why the hell can't people stop writing these kind of Train wreck sequences

    def post_process_request(self, req, template, data, content_type):
...
...
            for change in data.get('changes', []):
                for field, field_data in change['fields'].iteritems():

obviously in this case the change was Null or an empty object

... well, anyone in the mood to fix it?

comment:2 Changed 9 months ago by ichthyo

  • Status changed from new to closed
  • Resolution set to worksforme

solved by upgrading to Trac 0.12.2

Note: See TracTickets for help on using tickets.