Edgewall Software

Opened 12 years ago

Closed 9 years ago

#10907 closed defect (fixed)

TypeError: unhashable type: 'list' with malformed URL — at Version 9

Reported by: srl@… Owned by: Jun Omae
Priority: normal Milestone: 1.0.3
Component: query system Version: 0.12-stable
Severity: normal Keywords:
Cc: Branch:
Release Notes:

Fix crashing query page with multiple order or report parameters.

API Changes:
Internal Changes:

Description (last modified by Steven R. Loomis <srl@…>)

How to Reproduce

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

If the order= is specified twice, such as http://trac.edgewall.org/query?order=priority&order=owner trac will error. Issue is user may not be able to edit the custom query again. Probably the line specified needs to check whether "order" is a list, and do something sane like grab the first item.

Request parameters:

{'order': [u'priority', u'owner']}

User agent: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.4 (KHTML, like Gecko) Chrome/22.0.1229.79 Safari/537.4

System Information

System information not available

Enabled Plugins

Plugin information not available

Python Traceback

Traceback (most recent call last):
  File "/usr/local/virtualenv/1.1dev/lib/python2.6/site-packages/Trac-1.1.1dev_r11388-py2.6.egg/trac/web/main.py", line 497, in _dispatch_request
    dispatcher.dispatch(req)
  File "/usr/local/virtualenv/1.1dev/lib/python2.6/site-packages/Trac-1.1.1dev_r11388-py2.6.egg/trac/web/main.py", line 214, in dispatch
    resp = chosen_handler.process_request(req)
  File "/usr/local/virtualenv/1.1dev/lib/python2.6/site-packages/Trac-1.1.1dev_r11388-py2.6.egg/trac/ticket/query.py", line 938, in process_request
    max)
  File "/usr/local/virtualenv/1.1dev/lib/python2.6/site-packages/Trac-1.1.1dev_r11388-py2.6.egg/trac/ticket/query.py", line 78, in __init__
    self.order = synonyms.get(order, order)     # 0.11 compatibility
TypeError: unhashable type: 'list'

Change History (9)

comment:1 by Steven R. Loomis <srl@…>, 12 years ago

Description: modified (diff)

comment:2 by Christian Boos, 12 years ago

Component: generalquery system
Resolution: duplicate
Status: newclosed

Duplicate of #10838 (which got unnoticed so far, so thanks for reporting ;-) ).

in reply to:  2 comment:3 by Steven R. Loomis <srl@…>, 12 years ago

Replying to cboos:

Duplicate of #10838 (which got unnoticed so far, so thanks for reporting ;-) ).

Welcome! I really looked for a duplicate, but missed that one.

comment:4 by Jun Omae, 10 years ago

Milestone: 0.12.7
Resolution: duplicate
Status: closedreopened
Version: 1.0dev0.12-stable

I don't think this issue is a duplicate. It reproduces by query:? link with multiple orders like this.

query:?order=priority&order=id

If query: link doesn't have ? character, the issue doesn't occur.

query:order=priority&order=id
2014-09-30 16:21:23,133 Trac[main] ERROR: Internal Server Error:
Traceback (most recent call last):
  File "/home/jun66j5/src/tracdev/git/trac/web/main.py", line 529, in _dispatch_request
    dispatcher.dispatch(req)
  File "/home/jun66j5/src/tracdev/git/trac/web/main.py", line 243, in dispatch
    resp = chosen_handler.process_request(req)
  File "/home/jun66j5/src/tracdev/git/trac/ticket/query.py", line 939, in process_request
    max)
  File "/home/jun66j5/src/tracdev/git/trac/ticket/query.py", line 74, in __init__
    self.order = synonyms.get(order, order)     # 0.11 compatibility
TypeError: unhashable type: 'list'

comment:5 by Jun Omae, 9 years ago

Milestone: 0.12.71.0.3
Owner: set to Jun Omae
Status: reopenedassigned

Duplicated report parameters, e.g. query:?report=1&report=2, leads a similar issue.

Traceback (most recent call last):
  File "/venv/trac/0.12.6/lib/python2.4/site-packages/trac/web/main.py", line 529, in _dispatch_request
    dispatcher.dispatch(req)
  File "/venv/trac/0.12.6/lib/python2.4/site-packages/trac/web/main.py", line 243, in dispatch
    resp = chosen_handler.process_request(req)
  File "/venv/trac/0.12.6/lib/python2.4/site-packages/trac/ticket/query.py", line 960, in process_request
    return self.display_html(req, query)
  File "/venv/trac/0.12.6/lib/python2.4/site-packages/trac/ticket/query.py", line 1100, in display_html
    "WHERE id=%s", (query.id,))
  File "/venv/trac/0.12.6/lib/python2.4/site-packages/trac/db/util.py", line 61, in execute
    r = self.cursor.execute(sql_escape_percent(sql), args)
  File "/venv/trac/0.12.6/lib/python2.4/site-packages/trac/db/sqlite_backend.py", line 80, in execute
    result = PyFormatCursor.execute(self, *args)
  File "/venv/trac/0.12.6/lib/python2.4/site-packages/trac/db/sqlite_backend.py", line 58, in execute
    args or [])
  File "/venv/trac/0.12.6/lib/python2.4/site-packages/trac/db/sqlite_backend.py", line 50, in _rollback_on_error
    return function(self, *args, **kwargs)
InterfaceError: Error binding parameter 0 - probably unsupported type.

comment:6 by Jun Omae, 9 years ago

Proposed changes in jomae.git@t10907_1.0.

comment:7 by Ryan J Ollos, 9 years ago

Looks good. Just curious, is there a case in which order can be a tuple, or are you just protecting against future change?

Is this test addition useful?:

  • trac/ticket/tests/query.py

    diff --git a/trac/ticket/tests/query.py b/trac/ticket/tests/query.py
    index 3c0807c..5003203 100644
    a b class QueryLinksTestCase(unittest.TestCase):  
    659659        # query:?order=priority&order=id
    660660        data = self._query_with_duplicated_args('order', ['priority', 'id'])
    661661        self.assertEqual([], data['tickets'])
     662        self.assertEqual('priority', data['query'].order)
    662663
    663664    def test_duplicated_report_arguments(self):
    664665        # query:?report=1&report=2

in reply to:  7 comment:8 by Jun Omae, 9 years ago

Looks good. Just curious, is there a case in which order can be a tuple, or are you just protecting against future change?

Thanks for the reviewing. Well, no particular reason. But I think isinstance(obj, (list, tuple)) is an idiom in Python to detect array object.

Is this test addition useful?: […]

Yeah, that's useful. I'll commit the changes with your suggestion.

comment:9 by Jun Omae, 9 years ago

Release Notes: modified (diff)
Resolution: fixed
Status: assignedclosed

Committed in [13447] and merged to trunk in [13448].

Note: See TracTickets for help on using tickets.