Edgewall Software
Modify

Opened 5 years ago

Closed 5 years ago

#12198 closed defect (fixed)

KeyError: 'cnum'

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

Missing or invalid cnum parameter in request for ticket action comment-history or comment-diff doesn't result in a traceback.

API Changes:
Internal Changes:

Description

Another traceback that was found in the logs:

2015-09-03 02:47:34,418 Trac[main] ERROR: Internal Server Error:
Traceback (most recent call last):
  File "build/bdist.linux-i686/egg/trac/web/main.py", line 551, in _dispatch_request
    dispatcher.dispatch(req)
  File "build/bdist.linux-i686/egg/trac/web/main.py", line 244, in dispatch
    resp = chosen_handler.process_request(req)
  File "build/bdist.linux-i686/egg/trac/ticket/web_ui.py", line 182, in process_request
    return self._process_ticket_request(req)
  File "build/bdist.linux-i686/egg/trac/ticket/web_ui.py", line 554, in _process_ticket_request
    cnum = int(req.args['cnum'])
KeyError: 'cnum'

Attachments (0)

Change History (5)

comment:1 by Jun Omae, 5 years ago

What about logging with the req object and its referrer for trouble shooting?

  • trac/web/api.py

    diff --git a/trac/web/api.py b/trac/web/api.py
    index 59aa00325..0ea3e05af 100644
    a b class Request(object):  
    358358        raise AttributeError(name)
    359359
    360360    def __repr__(self):
    361         path_info = self.environ.get('PATH_INFO', '')
    362         return '<%s "%s %r">' % (self.__class__.__name__, self.method,
    363                                  path_info)
     361        uri = self.environ.get('PATH_INFO', '')
     362        qs = self.query_string
     363        if qs:
     364            uri += '?' + qs
     365        return '<%s "%s %r">' % (self.__class__.__name__, self.method, uri)
    364366
    365367    # Public API
    366368
  • trac/web/main.py

    diff --git a/trac/web/main.py b/trac/web/main.py
    index 1844c9b07..84a881fe9 100644
    a b def _send_user_error(req, env, e):  
    581581
    582582def send_internal_error(env, req, exc_info):
    583583    if env:
    584         env.log.error("Internal Server Error: %s",
     584        env.log.error("Internal Server Error: %r, referrer %r%s",
     585                      req, req.environ.get('HTTP_REFERER'),
    585586                      exception_to_unicode(exc_info[1], traceback=True))
    586587    message = exception_to_unicode(exc_info[1])
    587588    traceback = get_last_traceback()

After the patch:

2015-09-04 13:18:26,942 Trac[main] ERROR: Internal Server Error: <RequestWithSession "GET '/ticket/1?action=comment-diff'">, referrer None
Traceback (most recent call last):
  File "/src/tracdev/git/trac/web/main.py", line 554, in _dispatch_request
    dispatcher.dispatch(req)
  File "/src/tracdev/git/trac/web/main.py", line 247, in dispatch
    resp = chosen_handler.process_request(req)
  File "/src/tracdev/git/trac/ticket/web_ui.py", line 182, in process_request
    return self._process_ticket_request(req)
  File "/src/tracdev/git/trac/ticket/web_ui.py", line 554, in _process_ticket_request
    cnum = int(req.args['cnum'])
KeyError: 'cnum'

comment:2 by Ryan J Ollos, 5 years ago

Owner: set to Ryan J Ollos
Status: newassigned

comment:3 by Ryan J Ollos, 5 years ago

That looks useful. I'll test out the patch. Thanks!

comment:4 by Ryan J Ollos, 5 years ago

Release Notes: modified (diff)

comment:1 change committed to 1.0-stable in [14294], merged to trunk in [14295].

Proposed changes in log:rjollos.git:t12198_invalid_cnum.

comment:5 by Ryan J Ollos, 5 years ago

Resolution: fixed
Status: assignedclosed

Committed to 1.0-stable in [14307], merged to trunk in [14308].

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.