hot string replace does not handle numbers as parameter values

Bug #1250251 reported by andrew plunk
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
OpenStack Heat
Fix Released
Undecided
andrew plunk

Bug Description

problem:
When using a number as a param value in a str_replace function within a hot template, an exception is raised.

expected:
When using a number as a param value in the str_replace function, hot should handle the conversion to a string gracefully.

actual:
If you try to use a number as a parameter value to str_replace the following exception is raised:

Traceback (most recent call last):
  File "heat/tests/test_hot.py", line 190, in test_str_replace_number
    tmpl.resolve_replace(snippet))
  File "heat/engine/hot.py", line 256, in resolve_replace
    handle_str_replace, s)
  File "heat/engine/template.py", line 485, in _resolve
    return handle(recurse(v))
  File "heat/engine/hot.py", line 251, in handle_str_replace
    text = text.replace(key, value)
TypeError: expected a character buffer object

Template snippet that would cause this bug:

str_replace:
          template: |
            #!/bin/bash -v
            ...
            ./script/rails server -p %http_port% -d
          params:
            "%http_port%": 80

Changed in heat:
assignee: nobody → andrew plunk (andrew-plunk)
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/55927

Changed in heat:
status: New → In Progress
Steven Hardy (shardy)
Changed in heat:
milestone: none → icehouse-1
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix merged to heat (master)

Reviewed: https://review.openstack.org/55927
Committed: http://github.com/openstack/heat/commit/cc8acd8f1216ac734fde00a4d098881cdf8261dd
Submitter: Jenkins
Branch: master

commit cc8acd8f1216ac734fde00a4d098881cdf8261dd
Author: Andrew Plunk <email address hidden>
Date: Mon Nov 11 17:19:10 2013 -0600

    Using a number in str_replace causes an exception

    When passing in a number as a parameter value to the string replace
    function, an exception is raised. Cast the value as a string before
    using it in the string replace function.

    Change-Id: I38bdc8d97c7d1f9b62f52b0a783bf4d3fde3611a
    Closes-Bug: #1250251

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: icehouse-1 → 2014.1
Revision history for this message
Michal (fasihmurp) wrote :

Our personalised approach guarantees that your aesthetic goals are accomplished with accuracy and care since we recognise that each person is unique. https://thalderma-laser.de/leipzig/behandlungen-haarentfernung

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.