Number properties don't cast strings to numbers

Bug #1241276 reported by Christopher Armstrong
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
OpenStack Heat
Fix Released
Medium
Christopher Armstrong
Havana
Fix Released
Medium
Steve Baker

Bug Description

It seems that there is the _intent_ to convert strings to numbers, and they validate successfully, but in practice the conversion doesn't happen.

The bug is pretty obvious:

    def _validate_number(self, value):
        if value is None:
            value = self.has_default() and self.default() or 0

        num = self.str_to_num(value)

        return value

This should be returning 'num', not 'value'. Patch forthcoming.

Changed in heat:
assignee: nobody → Christopher Armstrong (radix)
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/52564

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/52564
Committed: http://github.com/openstack/heat/commit/a3bb8dc6e9ee916c1e72b3b99e25685c8b2cad0c
Submitter: Jenkins
Branch: master

commit a3bb8dc6e9ee916c1e72b3b99e25685c8b2cad0c
Author: Christopher Armstrong <email address hidden>
Date: Fri Oct 18 02:24:14 2013 +0000

    Convert str passed as Numbers/Integer to numbers

    Previously, if a number-in-a-string was passed as a Number or Integer
    property, it would be validated as correct but not be converted to
    an integer (it's clear that the code intended to do this but had a trivial
    bug).

    Unfortunately, making this change causes some backwards incompatibility.

    - Previously, an AllowedValues field could have strings in it, e.g.
      ['1', '3', '5'], and this would work if a string was passed as the
      real value.
    - Resource code that relied on users accidentally passing strings
      instead of numbers will now break, since it will actually be
      receiving real numbers.

    You can see evidence of this in the tests I had to update
    elsewhere. I don't believe any existing Heat resources are affected
    by this, but it is possible that there are some templates out there
    that will break.

    Change-Id: I879545cae5ca52f485803a8e172c5484f3920b67
    Closes-bug: #1241276

Changed in heat:
status: In Progress → Fix Committed
tags: added: havana-backport-potential
Changed in heat:
importance: Undecided → Medium
milestone: none → icehouse-1
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix proposed to heat (stable/havana)

Fix proposed to branch: stable/havana
Review: https://review.openstack.org/56834

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