Opened 8 years ago

Last modified 8 years ago

defect #91 (closed: DONE)

The patch of 0.11.3 encountered a SQL error on querying past iterations

Test Complete Size: 3 Test Complete Date: 05/24/2009
Documentation Complete Size: 0 Documentation Complete Date:
Acceptance Complete Size: 1 Acceptance Complete Date: 05/24/2009
Reported by: augustinus Owned by: ja11sop
Milestone: Clean up of Plugin with Patch Component: agiletrac patch to core
Version: Plugin 0.1.5 Keywords:
Cc: Blocked By:
Blocking: Patch SVN Revision:
Patch Trac Version: 0.11.3
In Iterations: 19 23

Description

Oops… Trac detected an internal error:

TypeError?: sequence item 0: expected string, NoneType? found

This is probably a local installation issue. Found a bug in Trac?

If you think this should work and you can reproduce the problem, you should consider reporting this to the Trac team.

Before you do that, though, please first try searching for similar issues, as it is quite likely that this problem has been reported before. For questions about installation and configuration of Trac, please try the mailing list instead of filing a ticket.

Otherwise, please ==== How to Reproduce ==== While doing a GET operation on /iterations, Trac issued an internal error. (please provide additional details here) Request parameters: {'show': u'all'} User Agent was: Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10.5; zh-TW; rv:1.9.0.6) Gecko/2009011912 Firefox/3.0.6 ==== System Information ==== Trac 0.11.3 Python 2.5.4 (r254:67916, Mar 3 2009, 13:42:10)
[GCC 4.2.1 20070719 [FreeBSD]] setuptools 0.6c9 SQLite 3.6.10 pysqlite 2.3.5 Genshi 0.5.1 mod_python 3.3.1 Pygments 1.0 Subversion 1.5.5 (r34862) jQuery: 1.2.6 ==== Python Traceback ==== Traceback (most recent call last): File "/usr/local/lib/python2.5/site-packages/Trac-0.11.3-py2.5.egg/trac/web/main.py", line 435, in _dispatch_request dispatcher.dispatch(req) File "/usr/local/lib/python2.5/site-packages/Trac-0.11.3-py2.5.egg/trac/web/main.py", line 205, in dispatch resp = chosen_handler.process_request(req) File "/usr/local/lib/python2.5/site-packages/Trac-0.11.3-py2.5.egg/trac/ticket/roadmap.py", line 380, in process_request iteration_info = TicketSystem(self.env).get_iteration_info(iteration, req, self.stats_provider) File "/usr/local/lib/python2.5/site-packages/Trac-0.11.3-py2.5.egg/trac/ticket/api.py", line 661, in get_iteration_info milestone_sizing_stats = self.get_sizing_statistics_for_milestones(milestones) File "/usr/local/lib/python2.5/site-packages/Trac-0.11.3-py2.5.egg/trac/ticket/api.py", line 445, in get_sizing_statistics_for_milestones "\',\'".join(milestones_names)) TypeError: sequence item 0: expected string, NoneType found a new ticket at the Trac project site, where you can describe the problem and explain how to reproduce it. Python Traceback Most recent call last:

  • File "/usr/local/lib/python2.5/site-packages/Trac-0.11.3-py2.5.egg/trac/web/main.py", line 435, in _dispatch_request Code fragment:
    1. try:
    2. if not env and env_error:
    3. raise HTTPInternalError(env_error)
    4. try:
    5. dispatcher = RequestDispatcher?(env)
    6. dispatcher.dispatch(req)
    7. except RequestDone?:
    8. pass
    9. resp = req._response or []
    10. 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 0x809591310> e TypeError?('sequence item 0: expected string, NoneType? found',) env <trac.env.Environment object at 0x80863a6d0> env_error None exc_info (<type 'exceptions.TypeError?'>, TypeError?('sequence item 0: expected ... filename '/usr/local/lib/python2.5/site-packages/Trac-0.11.3-py2.5.egg/trac/web/main ... frames [{'function': '_dispatch_request', 'lines_before': [u' try:', u' ... has_admin True line u' dispatcher.dispatch(req)' lineno 434 message u'TypeError?: sequence item 0: expected string, NoneType? found' req <Request "GET u'/iterations'"> resp [] tb <traceback object at 0x80d46fc20> tb_hide None traceback 'Traceback (most recent call last):\n File ...
  • File "/usr/local/lib/python2.5/site-packages/Trac-0.11.3-py2.5.egg/trac/web/main.py", line 205, in dispatch Code fragment:
    1. req.args.get('FORM_TOKEN') != req.form_token:
    2. raise HTTPBadRequest('Missing or invalid form token. '
    3. 'Do you have cookies enabled?')
    4. # Process the request and render the template
    5. resp = chosen_handler.process_request(req)
    6. if resp:
    7. if len(resp) == 2: # Clearsilver
    8. chrome.populate_hdf(req)
    9. template, content_type = \
    10. self._post_process_request(req, *resp)
  • Local variables: Name Value chosen_handler <trac.ticket.roadmap.IterationsModule? object at 0x809591a10> chrome <trac.web.chrome.Chrome object at 0x809518d10> err (<type 'exceptions.TypeError?'>, TypeError?('sequence item 0: expected ... handler <trac.ticket.roadmap.IterationsModule? object at 0x809591a10> req <Request "GET u'/iterations'"> self <trac.web.main.RequestDispatcher? object at 0x809591310>
  • File "/usr/local/lib/python2.5/site-packages/Trac-0.11.3-py2.5.egg/trac/ticket/roadmap.py", line 380, in process_request Code fragment:
    1. iterations.sort(lambda x, y: cmp(x.end_date, y.end_date)) 376.
    2. iterations_info = []
    3. for iteration in iterations:
    4. iteration_info = TicketSystem?(self.env).get_iteration_info(iteration, req, self.stats_provider)
    5. iterations_info.append( iteration_info )
    6. ticket_fields = TicketSystem?(self.env).get_ticket_fields()
    7. completion_stages = TicketSystem?(self.env).get_completion_stages() 385.
  • Local variables: Name Value db <trac.db.pool.PooledConnection? object at 0x80b752e18> i <trac.ticket.model.Iteration object at 0x80b67ebd0> iteration <trac.ticket.model.Iteration object at 0x80b488550> iteration_info {'ticket_info': {'done_size': 48, 'total_relative_size': 80, ... iterations [<trac.ticket.model.Iteration object at 0x80b4889d0>, ... iterations_info [{'ticket_info': {'done_size': 34, 'total_relative_size': 311, ... iterations_realm <Resource 'iteration'> req <Request "GET u'/iterations'"> self <trac.ticket.roadmap.IterationsModule? object at 0x809591a10> showall True
  • File "/usr/local/lib/python2.5/site-packages/Trac-0.11.3-py2.5.egg/trac/ticket/api.py", line 661, in get_iteration_info Code fragment:
    1. tickets = self.apply_ticket_permissions(req, tickets) 657.
    2. changed_tickets = self.get_changed_tickets_for_iteration(db, iteration) 659.
    3. milestones = self.get_milestones_for_tickets(tickets)
    4. milestone_sizing_stats = self.get_sizing_statistics_for_milestones(milestones) 662.
    5. end_date = date.today()
    6. if iteration.end_date:
    7. end_date = iteration.end_date.date()
  • Local variables: Name Value changed_tickets {1152: {'ticket': <trac.ticket.model.Ticket object at 0x80d21cdd0>, ... db <trac.db.pool.PooledConnection? object at 0x80b2a6128> iteration <trac.ticket.model.Iteration object at 0x80b488550> milestones set([None, u'Going9 Ultimate']) req <Request "GET u'/iterations'"> self <trac.ticket.api.TicketSystem? object at 0x80ad7e790> stats_provider <trac.ticket.roadmap.DefaultTicketGroupStatsProvider? object at ... tickets [<trac.ticket.model.Ticket object at 0x80cf62c10>, ...
  • File "/usr/local/lib/python2.5/site-packages/Trac-0.11.3-py2.5.egg/trac/ticket/api.py", line 445, in get_sizing_statistics_for_milestones Code fragment:
    1. sizing_stats[stage_name]count_defined_size? = 0
    2. sizing_stats[stage_name]min_size? = 0
    3. sizing_stats[stage_name]max_size? = 0 443.
    4. cursor.execute("SELECT tc.ticket,tc.stage,tc.size FROM ticket_completion tc, ticket t WHERE tc.ticket = t.id AND t.milestone IN (\'%s\')" %
    5. "\',\'".join(milestones_names)) 446.
    6. milestone_tickets = {} 448.
    7. for ticket, stage, size in cursor:
    8. milestone_tickets.setdefault( str(ticket), {} )[stage] = size
  • Local variables: Name Value Milestone <class 'trac.ticket.model.Milestone'> cursor <trac.db.util.IterableCursor? object at 0x80ce3a210> m <trac.ticket.model.Milestone object at 0x80d23a850> milestones_names set([None, u'Going9 Ultimate']) remaining_milestones [] self <trac.ticket.api.TicketSystem? object at 0x80ad7e790> sizing_stats {'acceptance_complete': {'min_size': 0, 'max_size': 0, ... stage {'order': 3, 'name': 'acceptance_complete', 'short_label': u'Acceptance', ... stage_name 'acceptance_complete' stages [{'order': 1, 'name': 'test_complete', 'short_label': u'Tested', 'label': ...

File "/usr/local/lib/python2.5/site-packages/Trac-0.11.3-py2.5.egg/trac/web/main.py", line 435, in _dispatch_request

dispatcher.dispatch(req)

File "/usr/local/lib/python2.5/site-packages/Trac-0.11.3-py2.5.egg/trac/web/main.py", line 205, in dispatch

resp = chosen_handler.process_request(req)

File "/usr/local/lib/python2.5/site-packages/Trac-0.11.3-py2.5.egg/trac/ticket/roadmap.py", line 380, in process_request

iteration_info = TicketSystem?(self.env).get_iteration_info(iteration, req, self.stats_provider)

File "/usr/local/lib/python2.5/site-packages/Trac-0.11.3-py2.5.egg/trac/ticket/api.py", line 661, in get_iteration_info

milestone_sizing_stats = self.get_sizing_statistics_for_milestones(milestones)

File "/usr/local/lib/python2.5/site-packages/Trac-0.11.3-py2.5.egg/trac/ticket/api.py", line 445, in get_sizing_statistics_for_milestones

"\',\'".join(milestones_names))

System Information:

User Agent: Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10.5; zh-TW; rv:1.9.0.6) Gecko/2009011912 Firefox/3.0.6 Trac: 0.11.3 Python: 2.5.4 (r254:67916, Mar 3 2009, 13:42:10) [GCC 4.2.1 20070719 [FreeBSD]] setuptools: 0.6c9 SQLite: 3.6.10 pysqlite: 2.3.5 Genshi: 0.5.1 mod_python: 3.3.1 Pygments: 1.0 Subversion: 1.5.5 (r34862) jQuery: 1.2.6

Change History

Have a look at the list of modified files related to this ticket.

  Changed 8 years ago by augustinus

 File "/usr/local/lib/python2.5/site-packages/Trac-0.11.3-py2.5.egg/trac/ticket/api.py", line 445, in  get_sizing_statistics_for_milestones
Code fragment:

 440. sizing_stats[stage_name]['count_defined_size'] = 0
 441. sizing_stats[stage_name]['min_size'] = 0
 442. sizing_stats[stage_name]['max_size'] = 0
 443.
 444. cursor.execute("SELECT tc.ticket,tc.stage,tc.size FROM ticket_completion tc, ticket t WHERE tc.ticket = t.id AND t.milestone IN (\'%s\')" %
 445. "\',\'".join(milestones_names))
 446.
 447. milestone_tickets = {}
 448.
 449. for ticket, stage, size in cursor:
 450. milestone_tickets.setdefault( str(ticket), {} )[stage] = size

  Changed 8 years ago by augustinus

I can reproduce it by  http://your.trac.site/trac/proj/iterations?show=all

Is .join(milestones_names) the problem?

  Changed 8 years ago by ja11sop

  • test_complete_size changed from undefined to 3
  • doc_complete_size changed from undefined to 0
  • acceptance_complete_size changed from undefined to 1

Thanks for the bug report. I've added this to the cleanup milestone and put it into the current iteration. We'll take at look at this shortly.

  Changed 8 years ago by augustinus

We found this caused by the set mailestones[None, u"some_milestone"] since it's highly possible there are some tickets without milestone. Therefore we chose to add if-else into get_milestones_for_tickets(ticket) as a workaround: {{[

def get_milestones_for_tickets(self, tickets):

milestones = set() for ticket in tickets:

if ticketmilestone?:

milestones.add(ticketmilestone?)

else:

milestones.add('None')

return milestones

}}}

  Changed 8 years ago by ja11sop

Thanks very much for tracing through the problem and providing a patch! I see what you are saying. I'll have a look at what other impact this might have and then apply the patch (or something very similar to it). Thanks again.

     def get_milestones_for_tickets(self, tickets):
         milestones = set()
         for ticket in tickets:
             if ticket['milestone']:
                 milestones.add(ticket['milestone'])
             else:
                 milestones.add('None')
         return milestones

follow-up: ↓ 7   Changed 8 years ago by ja11sop

I think recent fixes for postgresql 8.3 probably address this issue also. Can you please retest this with the latest svn revision? If it works for you let us know and we can progress this issue to done.

in reply to: ↑ 6   Changed 8 years ago by augustinus

Replying to ja11sop:

I think recent fixes for postgresql 8.3 probably address this issue also. Can you please retest this with the latest svn revision? If it works for you let us know and we can progress this issue to done.

I still encounter the same problem with SQLite if our private patch hadn't been applied.

  Changed 8 years ago by ja11sop

Ok thanks for the quick response. We'll look at getting some version of your patch added soon.

  Changed 8 years ago by ja11sop

The issue here is that if a ticket belongs to an iteration but is not associated with any milestone then we see this error. Reproducing it is therefore quite straightforward. The patch will solve this but we might be able to handle this in a slightly cleaner way.

  Changed 8 years ago by ja11sop

  • test_complete_date set to 05/24/09

A slightly different patch was applied. An empty string was used instead of 'None'.

  Changed 8 years ago by ja11sop

  • acceptance_complete_date set to 05/24/09
  • status changed from sized to closed
  • resolution set to DONE
Note: See TracTickets for help on using tickets.