Edgewall Software
Modify

Opened 7 years ago

Closed 7 years ago

Last modified 7 years ago

#12881 closed defect (fixed)

TypeError is raised caused by post_process_request in batch.py when no resolutions

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

Fix exception in BatchModify.post_process_request during error handling.

API Changes:
Internal Changes:

Description

How to reproduce

  1. Create an environemnt.
  2. Remove all resolutions.
  3. Create an new ticket.
  4. View /query?id=1 by a user granted TRAC_ADMIN.
  5. TypeError is raised.
07:59:43 PM Trac[main] DEBUG: Dispatching <RequestWithSession "GET '/query?id=1'">
07:59:43 PM Trac[session] DEBUG: Retrieving session for ID u'admin'
07:59:43 PM Trac[main] DEBUG: Negotiated locale: en_US -> en_US
07:59:43 PM Trac[api] WARNING: Unable to find repository '(default)' for synchronization
07:59:43 PM Trac[chrome] DEBUG: Prepare chrome data for request
07:59:43 PM Trac[query] DEBUG: Count results in Query: 1
07:59:43 PM Trac[default_workflow] DEBUG: render_ticket_action_control: action "leave"
07:59:43 PM Trac[default_workflow] DEBUG: render_ticket_action_control: action "resolve"
07:59:43 PM Trac[main] ERROR: Exception caught while post-processing request:
Traceback (most recent call last):
  File "/venv/trac/1.0.15/lib/python2.5/site-packages/trac/web/main.py", line 279, in dispatch
    self._post_process_request(req)
  File "/venv/trac/1.0.15/lib/python2.5/site-packages/trac/web/main.py", line 403, in _post_process_request
    f.post_process_request(req, *(None,)*extra_arg_count)
  File "/venv/trac/1.0.15/lib/python2.5/site-packages/trac/ticket/batch.py", line 80, in post_process_request
    self.add_template_data(req, data, data['tickets'])
TypeError: 'NoneType' object is unsubscriptable
07:59:43 PM Trac[main] WARNING: [192.168.11.25] HTTPInternalError: 500 Trac Error (Your workflow attempts to set a resolution but none is defined (configuration issue, please contact your Trac admin).), <RequestWithSession "GET '/query?id=1'">, referrer None
192.168.11.25 - - [07/Aug/2017 19:59:43] "GET /trac-1.0/query?id=1 HTTP/1.1" 500 -

It seems this issue is introduced in [15154] (#12591).

The following patch is to check whether template and data in post_process_request() are not None. Those variable would be None when an exception while invoking process_request() is raised.

  • trac/ticket/batch.py

    diff --git a/trac/ticket/batch.py b/trac/ticket/batch.py
    index 2be5f0485..8a129c920 100644
    a b class BatchModifyModule(Component):  
    7575        return handler
    7676
    7777    def post_process_request(self, req, template, data, content_type):
    78         if req.path_info == '/query' and \
     78        if template and data is not None and \
     79                req.path_info == '/query' and \
    7980                'TICKET_BATCH_MODIFY' in req.perm('ticket'):
    8081            self.add_template_data(req, data, data['tickets'])
    8182        return template, data, content_type

Attachments (0)

Change History (3)

comment:1 by Ryan J Ollos, 7 years ago

Owner: set to Ryan J Ollos
Status: newassigned

Thanks for catching my error. I will add a test before committing.

comment:2 by Ryan J Ollos, 7 years ago

Release Notes: modified (diff)
Resolution: fixed
Status: assignedclosed

Committed to 1.0-stable in r16268, merged to 1.2-stable in r16269, merged to trunk in r16270.

comment:3 by Ryan J Ollos, 7 years ago

Milestone: 1.0.161.0.17

Milestone renamed

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.