human-readable error messages on parser failures, not python stacktraces

Bug #1617421 reported by Steve Langasek
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Ubuntu Image
Fix Released
High
Barry Warsaw

Bug Description

I introduced a bug in my test gadget.yaml, and ubuntu-image told :

$ ./ubuntu-image -w workdir -d --resume
DEBUG:ubuntu-image:-> [ 2] load_gadget_yaml
ERROR:ubuntu-image:uncaught exception in state machine step: [2] load_gadget_yaml
Traceback (most recent call last):
  File "/home/vorlon/devel/canonical/ubuntu-image/ubuntu_image/helpers.py", line 85, in inner
    return func(*args, **kws)
  File "/home/vorlon/devel/canonical/ubuntu-image/ubuntu_image/parser.py", line 233, in parse
    validated = GadgetYAML(yaml)
  File "/usr/lib/python3/dist-packages/voluptuous/schema_builder.py", line 192, in __call__
    return self._compiled([], data)
  File "/usr/lib/python3/dist-packages/voluptuous/schema_builder.py", line 486, in validate_dict
    return base_validate(path, iteritems(data), out)
  File "/usr/lib/python3/dist-packages/voluptuous/schema_builder.py", line 324, in validate_mapping
    raise er.MultipleInvalid(errors)
voluptuous.error.MultipleInvalid: required key not provided @ data['volumes']['pc']['structure'][0]['type']

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/home/vorlon/devel/canonical/ubuntu-image/ubuntu_image/state.py", line 68, in __next__
    step()
  File "/home/vorlon/devel/canonical/ubuntu-image/ubuntu_image/builder.py", line 144, in load_gadget_yaml
    self.gadget = parse_yaml(fp)
  File "/home/vorlon/devel/canonical/ubuntu-image/ubuntu_image/helpers.py", line 87, in inner
    raise new_exc from exception
ValueError
ERROR:ubuntu-image:Crash in state machine
Traceback (most recent call last):
  File "/home/vorlon/devel/canonical/ubuntu-image/ubuntu_image/helpers.py", line 85, in inner
    return func(*args, **kws)
  File "/home/vorlon/devel/canonical/ubuntu-image/ubuntu_image/parser.py", line 233, in parse
    validated = GadgetYAML(yaml)
  File "/usr/lib/python3/dist-packages/voluptuous/schema_builder.py", line 192, in __call__
    return self._compiled([], data)
  File "/usr/lib/python3/dist-packages/voluptuous/schema_builder.py", line 486, in validate_dict
    return base_validate(path, iteritems(data), out)
  File "/usr/lib/python3/dist-packages/voluptuous/schema_builder.py", line 324, in validate_mapping
    raise er.MultipleInvalid(errors)
voluptuous.error.MultipleInvalid: required key not provided @ data['volumes']['pc']['structure'][0]['type']

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/home/vorlon/devel/canonical/ubuntu-image/ubuntu_image/__main__.py", line 110, in main
    list(state_machine)
  File "/home/vorlon/devel/canonical/ubuntu-image/ubuntu_image/state.py", line 68, in __next__
    step()
  File "/home/vorlon/devel/canonical/ubuntu-image/ubuntu_image/builder.py", line 144, in load_gadget_yaml
    self.gadget = parse_yaml(fp)
  File "/home/vorlon/devel/canonical/ubuntu-image/ubuntu_image/helpers.py", line 87, in inner
    raise new_exc from exception
ValueError

We should give the user human-readable error messages here precisely identifying the yaml syntax problem, not a page of scrolly backtrace.

Barry Warsaw (barry)
Changed in ubuntu-image:
milestone: none → 0.11
assignee: nobody → Barry Warsaw (barry)
importance: Undecided → High
Barry Warsaw (barry)
Changed in ubuntu-image:
status: New → In Progress
Revision history for this message
Barry Warsaw (barry) wrote :

Blocked currently on upstream voluptuous bug:

https://github.com/alecthomas/voluptuous/issues/239

Trying to figure out a workaround and/or fix.

Changed in ubuntu-image:
milestone: 0.11 → 0.12
Barry Warsaw (barry)
Changed in ubuntu-image:
status: In Progress → Fix Committed
Barry Warsaw (barry)
Changed in ubuntu-image:
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.