Edgewall Software
Modify

Opened 14 years ago

Closed 14 years ago

#9001 closed defect (fixed)

KeyError: 1

Reported by: Remy Blank Owned by: Remy Blank
Priority: high Milestone: 0.12
Component: ticket system Version: 0.12dev
Severity: normal Keywords:
Cc: Branch:
Release Notes:
API Changes:
Internal Changes:

Description

How to Reproduce

While doing a GET operation on /ticket/2635, Trac issued an internal error.

The error happens when trying to view the diffs of comment edits on comment:5:ticket:2635.

It would be very helpful to get the output of the following query:

SELECT time,author,field,oldvalue FROM ticket_change WHERE ticket=2635;

(Or a dump of the ticket_change table for ticket=2635)

Request parameters:

{'action': u'comment-diff', 'cnum': u'5', 'id': u'2635', 'version': u'2'}

User Agent was: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.1.7) Gecko/20091221 Firefox/3.5.7

System Information

Trac 0.12dev-r9078
Python 2.5.2 (r252:60911, Oct 5 2008, 19:29:17)
[GCC 4.3.2]
setuptools 0.6c9
psycopg2 2.0.8
Genshi 0.6dev-r1092
Babel 0.9.4
Pygments 1.1.1dev-20091217
Subversion 1.5.1 (r32289)
Docutils 0.6
jQuery 1.3.2

Enabled Plugins

Python Traceback

Traceback (most recent call last):
  File "build/bdist.linux-x86_64/egg/trac/web/main.py", line 495, in _dispatch_request
    dispatcher.dispatch(req)
  File "build/bdist.linux-x86_64/egg/trac/web/main.py", line 227, in dispatch
    resp = chosen_handler.process_request(req)
  File "build/bdist.linux-x86_64/egg/trac/ticket/web_ui.py", line 168, in process_request
    return self._process_ticket_request(req)
  File "build/bdist.linux-x86_64/egg/trac/ticket/web_ui.py", line 471, in _process_ticket_request
    return self._render_comment_diff(req, ticket, data, cnum)
  File "build/bdist.linux-x86_64/egg/trac/ticket/web_ui.py", line 945, in _render_comment_diff
    old_text = history[old_version]['value']
KeyError: 1

Attachments (0)

Change History (8)

comment:1 by Christian Boos, 14 years ago

If you don't have the REPORT permissions, tell me, I'll add them. In the meantime see: {38}

This issue (editing a comment which get saved under another one) has most likely to do with old unnumbered comments, hence again the probable need to add a renumber db upgrade step.

in reply to:  1 comment:2 by Remy Blank, 14 years ago

Replying to cboos:

If you don't have the REPORT permissions, tell me, I'll add them.

Heh, I hadn't thought of that ;) I'm not using reports nearly often enough. Thanks!

This issue (editing a comment which get saved under another one) has most likely to do with old unnumbered comments, hence again the probable need to add a renumber db upgrade step.

Yes, I'll probably do that. Still, I'd prefer that it doesn't throw an internal error even without the upgrade.

comment:3 by Christian Boos, 14 years ago

Actually the comments numbering seem to be fine:

12:34:51	anonymous	type	defect

15:47:03	mgood	comment	

09:25:22	Dave Matthews	comment	

11:17:17	cboos	comment	
11:17:17	cboos	keywords	
11:17:17	cboos	owner	jonas

20:18:47	cboos	_comment0	I'm going to need ...
20:18:47	cboos	_comment1	Being able to link to ...
20:18:47	stevegt	comment	

10:36:25	stevegt@terraluna.org	comment	

10:37:26	anonymous	comment	

00:50:21	anonymous	cc	

20:22:21	cboos	milestone	
20:22:21	cboos	comment	9
...

so there must be an off by one error somewhere.

Last edited 14 years ago by Christian Boos (previous) (diff)

in reply to:  3 comment:4 by Remy Blank, 14 years ago

Replying to cboos:

Actually the comments numbering seem to be fine:

Not quite. The edits at 12:34:51 and 00:50:21 don't have a comment field, and that's what I happen to use to number the comments in case the comment number is not available in oldvalue (I was mislead by this).

Let's see if I can find a more robust way to count edits…

comment:5 by Remy Blank, 14 years ago

Resolution: fixed
Status: newclosed

Fixed in [9107], together with unit tests for all sorts of special cases (which I should have added from the start).

Let's hope that I have finally covered all the pathological cases.

comment:6 by Christian Boos, 14 years ago

Resolution: fixed
Status: closedreopened

I saw this one in the logs this morning:

[pid  1121933648] 2010-03-22 10:28:50,308 Trac[main] ERROR: Internal Server Error:
Traceback (most recent call last):
  File "build/bdist.linux-x86_64/egg/trac/web/main.py", line 504, in _dispatch_request
    dispatcher.dispatch(req)
  File "build/bdist.linux-x86_64/egg/trac/web/main.py", line 235, in dispatch
    resp = chosen_handler.process_request(req)
  File "build/bdist.linux-x86_64/egg/trac/ticket/web_ui.py", line 169, in process_request
    return self._process_ticket_request(req)
  File "build/bdist.linux-x86_64/egg/trac/ticket/web_ui.py", line 472, in _process_ticket_request
    return self._render_comment_diff(req, ticket, data, cnum)
  File "build/bdist.linux-x86_64/egg/trac/ticket/web_ui.py", line 948, in _render_comment_diff
    new_text = history[new_version]['value']
KeyError: 1

for the request:

207.46.204.227 trac.edgewall.org - [22/Mar/2010:10:28:50 +0100] "GET /ticket/8902?action=comment-diff&cnum=5&version=1 HTTP/1.0" 500 9085 "-" "msnbot/2.0b (+http://search.msn.com/msnbot.htm)"

(reproducible)

comment:7 by Christian Boos, 14 years ago

Ok, there's no previous version for ticket:8902#comment:5 (not sure how they got the link), but perhaps we shouldn't throw an internal error in this case, perhaps rather a ResourceNotFound.

in reply to:  7 comment:8 by Remy Blank, 14 years ago

Resolution: fixed
Status: reopenedclosed

Replying to cboos:

we shouldn't throw an internal error in this case, perhaps rather a ResourceNotFound.

Done in [9392].

Modify Ticket

Change Properties
Set your email in Preferences
Action
as closed The owner will remain Remy Blank.
The resolution will be deleted. Next status will be 'reopened'.
to The owner will be changed from Remy Blank 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.