Opened 5 years ago

Closed 5 years ago

KeyError: 'type' is generated on the reports page if no types exist

Reported by: Owned by: ngpitt@… Ryan J Ollos normal BlackMagicTicketTweaksPlugin normal

Description

blackmagic.py line 153 assumes that the key types exists in dict data["fields"]. This is not the case if no types are specified in the given trac environment.

This is easily reproducible by clicking "Custom Query" under "View Tickets" when no types have been configured.

This error can be fixed by prefacing the for loop on line 153 with:

if "type" in data["fields"]:


comment:1 Changed 5 years ago by Ryan J Ollos

Owner: changed from obs to Ryan J Ollos new → assigned

Sounds easy enough to fix. If it's as straightforward as you suggest, I should have a fix committed shortly ;)

comment:2 Changed 5 years ago by anonymous

Oops! Include the 1st line after the for loop as well. It also includes data["fields"]["types"].

comment:3 Changed 5 years ago by Ryan J Ollos

Thanks. I'll push a patch in the morning.

comment:4 Changed 5 years ago by Ryan J Ollos

Are you running Trac 0.12 or greater?

comment:5 Changed 5 years ago by Ryan J Ollos

Resolution: → fixed assigned → closed

(In [12824]) Fixes #10975: Fixed KeyError when no ticket types are defined. Thanks to ngpitt@… for the patch.

comment:6 follow-up:  7 Changed 5 years ago by Ivanelson Nunes

This error has been corrected in this ticket! Or I am wrong? I downloaded and installed the current version, but also restarted Apache. But the error continues:

Traceback (most recent call last):
File "/usr/local/lib/python2.7/dist-packages/Trac-1.0-py2.7.egg/trac/web/main.
py", line 497, in _dispatch_request
dispatcher.dispatch(req)
File "/usr/local/lib/python2.7/dist-packages/Trac-1.0-py2.7.egg/trac/web/main.
py", line 224, in dispatch
self._post_process_request(req, *resp)
File "/usr/local/lib/python2.7/dist-packages/Trac-1.0-py2.7.egg/trac/web/main.
py", line 338, in _post_process_request
resp = f.post_process_request(req, *resp)
File "/usr/local/lib/python2.7/dist-packages/BlackMagicTicketTweaks-0.12r1-py2
.7.egg/blackmagic/blackmagic.py", line 99, in post_process_request
data["numrows"]-=self.blockedTickets;
KeyError: 'numrows'


My Trac1.0.

Thanks

comment:7 in reply to:  6 ; follow-up:  8 Changed 5 years ago by Ryan J Ollos

This error has been corrected in this ticket! Or I am wrong?

The issue reported in comment:description is different than the issue you are reporting. It should be fairly easy to fix though. Let's make a separate ticket for the issue you are reporting.

comment:8 in reply to:  7 ; follow-up:  9 Changed 5 years ago by Ivanelson Nunes

This error has been corrected in this ticket! Or I am wrong?

The issue reported in comment:description is different than the issue you are reporting. It should be fairly easy to fix though. Let's make a separate ticket for the issue you are reporting.

You will open the Ticket? Or I can create the Ticket?

comment:9 in reply to:  8 Changed 5 years ago by Ivanelson Nunes

This error has been corrected in this ticket! Or I am wrong?

The issue reported in comment:description is different than the issue you are reporting. It should be fairly easy to fix though. Let's make a separate ticket for the issue you are reporting.

You will open the Ticket? Or I can create the Ticket?

Ticket opened: https://trac-hacks.org/ticket/11140

Modify Ticket

Change Properties