Traceback instead of error message when argument's format for get_attr is wrong

Bug #1411721 reported by Tatiana Kholkina
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
OpenStack Heat
Fix Released
Medium
Tatiana Kholkina

Bug Description

When trying to create stack with the following template

heat_template_version: 2013-05-23

resources:
  random_str:
    type: OS::Heat::RandomString

outputs:
  string:
    value: {get_attr: [[random_str, value]]}

heat shows traceback instead of error message:

ERROR: Arguments to "get_attr" must be of the form [resource_name, attribute, (path), ...]
Traceback (most recent call last):

  File "/usr/local/lib/python2.7/dist-packages/oslo/messaging/rpc/dispatcher.py", line 134, in _dispatch_and_reply
    incoming.message))

  File "/usr/local/lib/python2.7/dist-packages/oslo/messaging/rpc/dispatcher.py", line 177, in _dispatch
    return self._do_dispatch(endpoint, method, ctxt, args)

  File "/usr/local/lib/python2.7/dist-packages/oslo/messaging/rpc/dispatcher.py", line 123, in _do_dispatch
    result = getattr(endpoint, method)(ctxt, **new_args)

  File "/usr/local/lib/python2.7/dist-packages/osprofiler/profiler.py", line 105, in wrapper
    return f(*args, **kwargs)

  File "/opt/stack/heat/heat/engine/service.py", line 72, in wrapped
    return func(self, ctx, *args, **kwargs)

  File "/opt/stack/heat/heat/engine/service.py", line 607, in create_stack
    stack_user_project_id)

  File "/opt/stack/heat/heat/engine/service.py", line 517, in _parse_template_and_validate_stack
    **common_params)

  File "/opt/stack/heat/heat/engine/stack.py", line 142, in __init__
    self.outputs = self.resolve_static_data(self.t[self.t.OUTPUTS])

  File "/opt/stack/heat/heat/engine/stack.py", line 1196, in resolve_static_data
    return self.t.parse(self, snippet)

  File "/opt/stack/heat/heat/engine/template.py", line 179, in parse
    return parse(self.functions, stack, snippet)

  File "/opt/stack/heat/heat/engine/template.py", line 218, in parse
    return dict((k, recurse(v)) for k, v in six.iteritems(snippet))

  File "/opt/stack/heat/heat/engine/template.py", line 218, in <genexpr>
    return dict((k, recurse(v)) for k, v in six.iteritems(snippet))

  File "/opt/stack/heat/heat/engine/template.py", line 218, in parse
    return dict((k, recurse(v)) for k, v in six.iteritems(snippet))

  File "/opt/stack/heat/heat/engine/template.py", line 218, in <genexpr>
    return dict((k, recurse(v)) for k, v in six.iteritems(snippet))

  File "/opt/stack/heat/heat/engine/template.py", line 217, in parse
    return Func(stack, fn_name, recurse(args))

  File "/opt/stack/heat/heat/engine/cfn/functions.py", line 154, in __init__
    self._resource_name, self._attribute = self._parse_args()

  File "/opt/stack/heat/heat/engine/hot/functions.py", line 110, in _parse_args
    self.fn_name)

ValueError: Arguments to "get_attr" must be of the form [resource_name, attribute, (path), ...]

Changed in heat:
assignee: nobody → Tetiana Lashchova (tlashchova)
Revision history for this message
Joe D'Andrea (jdandrea) wrote :

Hi Tetiana,

Can you please try again without double brackets, like this?

outputs:
  string:
    value: {get_attr: [random_str, value]}

That should work, per the error message. Let me know!

Revision history for this message
Tatiana Kholkina (tlashchova) wrote :

Hi Joe,

Thanks for your reply. Yes, it works without double brackets. But I think the user should see short error message instead of traceback if he writes something wrong in the template.

Revision history for this message
Steve Baker (steve-stevebaker) wrote :

The ValueError needs to be wrapped in a exception.StackValidationFailed in the appropriate place.

Changed in heat:
status: New → Triaged
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix proposed to heat (master)

Fix proposed to branch: master
Review: https://review.openstack.org/149014

Changed in heat:
status: Triaged → In Progress
Changed in heat:
importance: Undecided → Medium
milestone: none → kilo-2
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix merged to heat (master)

Reviewed: https://review.openstack.org/149014
Committed: https://git.openstack.org/cgit/openstack/heat/commit/?id=15ba5c1eb0ccb1ecc1fb4cbcf73b301412295173
Submitter: Jenkins
Branch: master

commit 15ba5c1eb0ccb1ecc1fb4cbcf73b301412295173
Author: Tetiana Lashchova <email address hidden>
Date: Wed Jan 21 19:55:13 2015 +0200

    Enhanced error handling in outputs block

    Change-Id: I20cab805d7a423efc008049c447bde0747530970
    Closes-bug: #1411721

Changed in heat:
status: In Progress → Fix Committed
Thierry Carrez (ttx)
Changed in heat:
status: Fix Committed → Fix Released
Thierry Carrez (ttx)
Changed in heat:
milestone: kilo-2 → 2015.1.0
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.