Modify ↓
Opened 8 years ago
Closed 8 years ago
#12697 closed defect (fixed)
QuerySyntaxError: Query filter requires field and constraints separated by a "="
Reported by: | Ryan J Ollos | Owned by: | Ryan J Ollos |
---|---|---|---|
Priority: | normal | Milestone: | 1.2.1 |
Component: | query system | Version: | |
Severity: | normal | Keywords: | |
Cc: | Branch: | ||
Release Notes: |
Error message is displayed rather than traceback when |
||
API Changes: | |||
Internal Changes: |
Description
The traceback below appears in the logs when [[TicketQuery(keywords~=firefox&chrome, format=table)]]
.
See also #12286. I need to review this, but I think we settled on the MacroError
pattern:
-
trac/ticket/query.py
diff --git a/trac/ticket/query.py b/trac/ticket/query.py index 1f3fca98c..30d580b46 100644
a b from trac.web.chrome import (INavigationContributor, Chrome, 46 46 add_script_data, add_stylesheet, add_warning, 47 47 web_context) 48 48 from trac.wiki.api import IWikiSyntaxProvider 49 from trac.wiki.formatter import system_message49 from trac.wiki.formatter import MacroError 50 50 from trac.wiki.macros import WikiMacroBase 51 51 52 52 … … class TicketQueryMacro(WikiMacroBase): 1354 1354 query_string += '&' 1355 1355 1356 1356 query_string += '&'.join('%s=%s' % item for item in kwargs.iteritems()) 1357 query = Query.from_string(self.env, query_string) 1357 try: 1358 query = Query.from_string(self.env, query_string) 1359 except QuerySyntaxError as e: 1360 raise MacroError(e) 1358 1361 1359 1362 if format in ('count', 'rawcount'): 1360 1363 cnt = query.count(req) … … class TicketQueryMacro(WikiMacroBase): 1370 1373 try: 1371 1374 tickets = query.execute(req) 1372 1375 except QueryValueError as e: 1373 self.log.warning(e) 1374 return system_message(_("Error executing TicketQuery macro"), e) 1376 raise MacroError(e) 1375 1377 1376 1378 if format == 'table': 1377 1379 data = query.template_data(formatter.context, tickets, -
trac/wiki/formatter.py
diff --git a/trac/wiki/formatter.py b/trac/wiki/formatter.py index 7ca620540..9f7efc454 100644
a b class Formatter(object): 794 794 try: 795 795 return macro.ensure_inline(macro.process(args)) 796 796 except MacroError as e: 797 return system_message(e) 797 return system_message(_("Macro %(name)s(%(args)s) failed", 798 name=name, args=args), to_unicode(e)) 798 799 except Exception as e: 799 800 self.env.log.error('Macro %s(%s) failed:%s', name, args, 800 801 exception_to_unicode(e, traceback=True))
With the change, the error message would be:
[pid 23603 140352200914688] 2017-02-21 11:07:53,460 Trac[formatter] ERROR: Macro TicketQuery(keywords~=firefox&chrome, format=table) failed: Traceback (most recent call last): File "/usr/local/virtualenv/1.3dev/lib/python2.7/site-packages/trac/wiki/formatter.py", line 795, in _macro_formatter return macro.ensure_inline(macro.process(args)) File "/usr/local/virtualenv/1.3dev/lib/python2.7/site-packages/trac/wiki/formatter.py", line 371, in process text = self.processor(text) File "/usr/local/virtualenv/1.3dev/lib/python2.7/site-packages/trac/wiki/formatter.py", line 343, in _macro_processor text) File "/usr/local/virtualenv/1.3dev/lib/python2.7/site-packages/trac/ticket/query.py", line 1357, in expand_macro query = Query.from_string(self.env, query_string) File "/usr/local/virtualenv/1.3dev/lib/python2.7/site-packages/trac/ticket/query.py", line 169, in from_string raise QuerySyntaxError(_('Query filter requires field and ' QuerySyntaxError: Query filter requires field and constraints separated by a "="
Attachments (0)
Change History (3)
comment:3 by , 8 years ago
Release Notes: | modified (diff) |
---|---|
Resolution: | → fixed |
Status: | assigned → closed |
Note:
See TracTickets
for help on using tickets.
(FWIW: I was trying to remember how this hidden feature works:
But I had to search for #10152 instead.)