Modify

Opened 12 years ago

Last modified 6 years ago

#9622 new defect

ProgrammingError: (1064, "You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ')' at line 1")

Reported by: laurynas.riliskis@… Owned by:
Priority: normal Component: SumStatsPlugin
Severity: normal Keywords: database api string interpolation
Cc: Trac Release: 0.12

Description

The error occurend then I selected to list completed milestones

How to Reproduce

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

(please provide additional details here)

Request parameters:

{'show': u'completed'}

User agent: Mozilla/5.0 (Ubuntu; X11; Linux x86_64; rv:8.0) Gecko/20100101 Firefox/8.0

System Information

Trac 0.13dev-r10883
Babel 0.9.4
Docutils 0.6
Genshi 0.6
mod_wsgi 3.2 (WSGIProcessGroup WSGIApplicationGroup %{GLOBAL})
MySQL server: "5.1.52", client: "5.1.52", thread-safe: 0
MySQLdb 1.2.3c1
Pygments 1.1.1
Python 2.6.5 (r265:79063, Jun 25 2011, 08:36:25)
[GCC 4.4.4 20100726 (Red Hat 4.4.4-13)]
setuptools 0.6
Subversion 1.6.11 (r934486)
jQuery 1.5.1

Enabled Plugins

NavAdd 0.1
Trac-jsGantt 0.9-r10876
TracAccountManager 0.3.2
TracListOfWikiPagesMacro 0.4
TracSumStats 0.9.0
WikiTableMacro 0.1-r10442

Python Traceback

Traceback (most recent call last):
  File "/usr/lib/python2.6/site-packages/Trac-0.13dev_r10883-py2.6.egg/trac/web/main.py", line 478, in _dispatch_request
    dispatcher.dispatch(req)
  File "/usr/lib/python2.6/site-packages/Trac-0.13dev_r10883-py2.6.egg/trac/web/main.py", line 198, in dispatch
    resp = chosen_handler.process_request(req)
  File "/usr/lib/python2.6/site-packages/Trac-0.13dev_r10883-py2.6.egg/trac/ticket/roadmap.py", line 436, in process_request
    stat = get_ticket_stats(self.stats_provider, tickets)
  File "/usr/lib/python2.6/site-packages/Trac-0.13dev_r10883-py2.6.egg/trac/ticket/roadmap.py", line 293, in get_ticket_stats
    return provider.get_ticket_group_stats([t['id'] for t in tickets])
  File "/usr/lib/python2.6/site-packages/TracSumStats-0.9.0-py2.6.egg/sumstats/web_ui.py", line 133, in get_ticket_group_stats
    for group in self._get_groups(ticket_ids):
  File "/usr/lib/python2.6/site-packages/TracSumStats-0.9.0-py2.6.egg/sumstats/web_ui.py", line 32, in _get_groups
    self._update_group(group, ticket_ids)
  File "/usr/lib/python2.6/site-packages/TracSumStats-0.9.0-py2.6.egg/sumstats/web_ui.py", line 45, in _update_group
    group['total'] = self._get_total(group, field, ticket_ids)
  File "/usr/lib/python2.6/site-packages/TracSumStats-0.9.0-py2.6.egg/sumstats/web_ui.py", line 124, in _get_total
    cursor.execute(query)
  File "/usr/lib/python2.6/site-packages/Trac-0.13dev_r10883-py2.6.egg/trac/db/util.py", line 66, in execute
    return self.cursor.execute(sql)
  File "/usr/lib64/python2.6/site-packages/MySQLdb/cursors.py", line 173, in execute
    self.errorhandler(self, exc, value)
  File "/usr/lib64/python2.6/site-packages/MySQLdb/connections.py", line 36, in defaulterrorhandler
    raise errorclass, errorvalue
ProgrammingError: (1064, "You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ')' at line 1")

Attachments (0)

Change History (5)

comment:1 Changed 12 years ago by Ryan J Ollos

Component: SELECT A HACKSumStatsPlugin
Owner: changed from anonymous to Rob Guttman

comment:2 Changed 12 years ago by Rob Guttman

I have not tested this plugin yet for Trac 0.13 dev - clearly there's some issue with it. I hesitate to invest to 0.13 just yet as its schema may not yet be stable. I'll see if I can find some time to check it out, but I haven't even started 0.13 based plugin development yet.

(Thanks, rjollos.)

comment:3 Changed 12 years ago by Rob Guttman

Laurynas, can you copy your relevant trac.ini config here?

comment:4 Changed 11 years ago by Ryan J Ollos

Keywords: database api string interpolation added

The issue appears to be that the Trac database API is not being utilized correctly. See t:TracDev/DatabaseApi#RulesforDBAPIUsage for more info. This is probably the most common issue seen with plugins on trac-hacks (it would at least give unicode decode error a run for title spot).

String interpolation shouldn't be used to pass rhs variables to the SQL. Rather, arguments should be passed, cursor.execute(sql, (arg1, arg2, ...)).

I could workup a patch if there is interest. It looks fairly easy to fix the issue since there are only 2 executes in the codebase.

comment:5 Changed 6 years ago by Ryan J Ollos

Owner: Rob Guttman deleted

Modify Ticket

Change Properties
Set your email in Preferences
Action
as new The ticket will remain with no owner.

Add Comment


E-mail address and name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.