Traceback instead of error message when output or resource body is empty or a string

Bug #1386242 reported by Peter Razumovsky
10
This bug affects 2 people
Affects Status Importance Assigned to Milestone
OpenStack Heat
Fix Released
Undecided
Peter Razumovsky

Bug Description

1) Empty output body.
1.
heat_template_version: 2013-05-23
parameters:
  image:
    type: string
resources:
  server:
    type: OS::Nova::Server
    properties:
      image: { get_param: image }
      flavor: m1.small
outputs:
  output1:
2.
$ heat stack-create test -f test.yaml -P image=test
ERROR: 'NoneType' object has no attribute 'iteritems'
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 73, in wrapped
    return func(self, ctx, *args, **kwargs)

  File "/opt/stack/heat/heat/engine/service.py", line 663, in create_stack
    owner_id)

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

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

  File "/opt/stack/heat/heat/engine/hot/template.py", line 108, in __getitem__
    return self._translate_outputs(the_section)

  File "/opt/stack/heat/heat/engine/hot/template.py", line 158, in _translate_outputs
    for attr, attr_value in six.iteritems(attrs):

  File "/usr/local/lib/python2.7/dist-packages/six.py", line 565, in iteritems
    return iter(d.iteritems(**kw))

AttributeError: 'NoneType' object has no attribute 'iteritems'

2) Empty resource body
1.
heat_template_version: 2013-05-23
parameters:
  image:
    type: string
resources:
  server:
2.
$ heat stack-create test -f test.yaml -P image=test
ERROR: 'NoneType' object has no attribute 'iteritems'
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 73, in wrapped
    return func(self, ctx, *args, **kwargs)

  File "/opt/stack/heat/heat/engine/service.py", line 705, in update_stack
    if len(tmpl[tmpl.RESOURCES]) > cfg.CONF.max_resources_per_stack:

  File "/opt/stack/heat/heat/engine/hot/template.py", line 105, in __getitem__
    return self._translate_resources(the_section)

  File "/opt/stack/heat/heat/engine/hot/template.py", line 138, in _translate_resources
    for attr, attr_value in six.iteritems(attrs):

  File "/usr/local/lib/python2.7/dist-packages/six.py", line 565, in iteritems
    return iter(d.iteritems(**kw))

AttributeError: 'NoneType' object has no attribute 'iteritems'

3) Output body is a string
1.
heat_template_version: 2013-05-23
resources:
  server:
    type: OS::Nova::Server
    properties:
      flavor: m1.small
outputs:
  output1:
    This is not a string, this is error-raisable situation
2.
$ heat stack-create test -f test.yaml
ERROR: 'unicode' object has no attribute 'iteritems'
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 73, in wrapped
    return func(self, ctx, *args, **kwargs)

  File "/opt/stack/heat/heat/engine/service.py", line 663, in create_stack
    owner_id)

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

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

  File "/opt/stack/heat/heat/engine/hot/template.py", line 108, in __getitem__
    return self._translate_outputs(the_section)

  File "/opt/stack/heat/heat/engine/hot/template.py", line 158, in _translate_outputs
    for attr, attr_value in six.iteritems(attrs):

  File "/usr/local/lib/python2.7/dist-packages/six.py", line 565, in iteritems
    return iter(d.iteritems(**kw))

AttributeError: 'unicode' object has no attribute 'iteritems'

Changed in heat:
assignee: nobody → Razumovsky Peter (prazumovsky)
description: updated
description: updated
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/131169

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

Reviewed: https://review.openstack.org/131169
Committed: https://git.openstack.org/cgit/openstack/heat/commit/?id=5b09e4524a467a4df41ca9e88a571d2bae1ae9b6
Submitter: Jenkins
Branch: master

commit 5b09e4524a467a4df41ca9e88a571d2bae1ae9b6
Author: Peter Razumovsky <email address hidden>
Date: Mon Oct 27 17:36:22 2014 +0300

    Correct error msg when resource or output are empty

    When resource or output body is empty, we get traceback
    instead of error message. This is wrong, so this patch
    handle such situation by raising StackValidationFailed
    exception. Furthermore, if output body is not a mapping,
    we got traceback too.

    Change-Id: I27f3a732480a851fd2eceb83e5fcc850ee59bb73
    Closes-bug: #1386242

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