Modify ↓
#11915 closed defect (fixed)
Workflow macro should trap exceptions when parsing content
Reported by: | Ryan J Ollos | Owned by: | Ryan J Ollos |
---|---|---|---|
Priority: | normal | Milestone: | 1.0.5 |
Component: | ticket system | Version: | |
Severity: | normal | Keywords: | workflow macro |
Cc: | Branch: | ||
Release Notes: |
The WorkflowMacro traps parsing exceptions and display a system message with the error. The error messages are properly wrapped at line breaks. |
||
API Changes: | |||
Internal Changes: |
Description
The following content will raise a ParsingError
:
accept = new,accepted -> accepted accept.permissions = TICKET_MODIFY accept.operations = set_owner_to_self
An error is found in the logs:
11:01:18 PM Trac[formatter] ERROR: Processor Workflow failed: Traceback (most recent call last): File "/home/user/Workspace/t11944/teo-rjollos.git/trac/wiki/formatter.py", line 1181, in _exec_processor return processor.process(text) File "/home/user/Workspace/t11944/teo-rjollos.git/trac/wiki/formatter.py", line 358, in process text = self.processor(text) File "/home/user/Workspace/t11944/teo-rjollos.git/trac/wiki/formatter.py", line 342, in _macro_processor text, self.args) File "/home/user/Workspace/t11944/teo-rjollos.git/trac/ticket/default_workflow.py", line 479, in expand_macro parser.readfp(StringIO(text)) File "/usr/lib/python2.7/ConfigParser.py", line 324, in readfp self._read(fp, filename) File "/usr/lib/python2.7/ConfigParser.py", line 546, in _read raise e ParsingError: File contains parsing errors: <???> [line 2]: u' accept = new,accepted -> accepted\n' ParsingError: File contains parsing errors: <???> [line 2]: u' accept = new,accepted -> accepted\n' [line 3]: u' accept.permissions = TICKET_MODIFY\n'
The following patch would fix the issue, but it would be nice to have the line breaks in the error message rendered.
-
trac/ticket/default_workflow.py
diff --git a/trac/ticket/default_workflow.py b/trac/ticket/default_workflow.py index a9b614d..1536889 100644
a b 16 16 # 17 17 # Author: Eli Carter 18 18 19 from ConfigParser import RawConfigParser19 from ConfigParser import ParsingError, RawConfigParser 20 20 from StringIO import StringIO 21 21 from collections import defaultdict 22 22 from functools import partial … … from trac.util import get_reporter_id, to_list 34 34 from trac.util.presentation import separated 35 35 from trac.util.translation import _, tag_, cleandoc_ 36 36 from trac.web.chrome import Chrome, add_script, add_script_data 37 from trac.wiki.formatter import system_message 37 38 from trac.wiki.macros import WikiMacroBase 38 39 39 40 # -- Utilities for the ConfigurableTicketWorkflow … … class WorkflowMacro(WikiMacroBase): 476 477 if '[ticket-workflow]' not in text: 477 478 text = '[ticket-workflow]\n' + text 478 479 parser = RawConfigParser() 479 parser.readfp(StringIO(text)) 480 try: 481 parser.readfp(StringIO(text)) 482 except ParsingError, e: 483 return system_message(_("Error parsing workflow."), 484 unicode(e)) 480 485 raw_actions = list(parser.items('ticket-workflow')) 481 486 actions = parse_workflow_config(raw_actions) 482 487 states = list(set(
Attachments (1)
Change History (6)
by , 10 years ago
Attachment: | WorkflowMacro.png added |
---|
comment:1 by , 10 years ago
comment:2 by , 10 years ago
Milestone: | next-stable-1.0.x → 1.0.4 |
---|---|
Owner: | set to |
Status: | new → assigned |
comment:3 by , 10 years ago
Milestone: | 1.0.4 → 1.0.5 |
---|
comment:4 by , 10 years ago
Release Notes: | modified (diff) |
---|---|
Resolution: | → fixed |
Status: | assigned → closed |
Thanks for the review. Committed to 1.0-stable in [13725], merged to trunk in [13726:13727].
comment:5 by , 10 years ago
Release Notes: | modified (diff) |
---|
Note:
See TracTickets
for help on using tickets.
Looks good.
Another thing, the error message is contained in
pre
element. However, that is rendered aswhite-space: normal
. The style is introduced in [5360].I think we should use
white-space: pre-wrap
instead.trac/htdocs/css/trac.css
normal;