Edgewall Software
Modify

Opened 9 years ago

Closed 9 years ago

Last modified 9 years ago

#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  
    1616#
    1717# Author: Eli Carter
    1818
    19 from ConfigParser import RawConfigParser
     19from ConfigParser import ParsingError, RawConfigParser
    2020from StringIO import StringIO
    2121from collections import defaultdict
    2222from functools import partial
    from trac.util import get_reporter_id, to_list  
    3434from trac.util.presentation import separated
    3535from trac.util.translation import _, tag_, cleandoc_
    3636from trac.web.chrome import Chrome, add_script, add_script_data
     37from trac.wiki.formatter import system_message
    3738from trac.wiki.macros import WikiMacroBase
    3839
    3940# -- Utilities for the ConfigurableTicketWorkflow
    class WorkflowMacro(WikiMacroBase):  
    476477            if '[ticket-workflow]' not in text:
    477478                text = '[ticket-workflow]\n' + text
    478479            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))
    480485            raw_actions = list(parser.items('ticket-workflow'))
    481486        actions = parse_workflow_config(raw_actions)
    482487        states = list(set(

Attachments (1)

WorkflowMacro.png (17.3 KB ) - added by Ryan J Ollos 9 years ago.

Download all attachments as: .zip

Change History (6)

by Ryan J Ollos, 9 years ago

Attachment: WorkflowMacro.png added

comment:1 by Jun Omae, 9 years ago

Looks good.

Another thing, the error message is contained in pre element. However, that is rendered as white-space: normal. The style is introduced in [5360].

I think we should use white-space: pre-wrap instead.

  • trac/htdocs/css/trac.css

    diff --git a/trac/htdocs/css/trac.css b/trac/htdocs/css/trac.css
    index 274761f..491815c 100644
    a b table.listing pre { white-space: pre-wrap }  
    732732#content.error div.message pre, div.system-message pre {
    733733  margin-left: 1em;
    734734  overflow: hidden;
    735   white-space: normal;
     735  white-space: pre-wrap;
    736736}
    737737
    738738div.system-message p { margin: 0 }

comment:2 by Ryan J Ollos, 9 years ago

Milestone: next-stable-1.0.x1.0.4
Owner: set to Ryan J Ollos
Status: newassigned

comment:3 by Ryan J Ollos, 9 years ago

Milestone: 1.0.41.0.5

comment:4 by Ryan J Ollos, 9 years ago

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

Thanks for the review. Committed to 1.0-stable in [13725], merged to trunk in [13726:13727].

comment:5 by Ryan J Ollos, 9 years ago

Release Notes: modified (diff)

Modify Ticket

Change Properties
Set your email in Preferences
Action
as closed The owner will remain Ryan J Ollos.
The resolution will be deleted. Next status will be 'reopened'.
to The owner will be changed from Ryan J Ollos to the specified user.

Add Comment


E-mail address and name can be saved in the Preferences .
 
Note: See TracTickets for help on using tickets.