"TypeError: string indices must be integers" during 043 migration

Bug #1396313 reported by Jason Dunsmore
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
OpenStack Heat
Fix Released
High
Visnusaran Murugan

Bug Description

Migration scripts 037, 041, and 043 treat raw_template.template as if it were a dict, but it's actually a string. In those scripts, raw_template is a RowProxy object, not a RawTemplate object (where raw_template.template would, in fact, be a dict). Furthermore, a RowProxy object does not allow attributes to be set, yet that's exactly what those migration scripts do.

The bug will manifest itself with the following test in test_migrations.py:

    def _pre_upgrade_049(self, engine):
        raw_template = utils.get_table(engine, 'raw_template')
        templ = '''{"HeatTemplateFormatVersion" : "2012-12-12",
        "Parameters" : {
          "foo" : { "Type" : "String", "NoEcho": "True" },
          "bar" : { "Type" : "String", "NoEcho": "True", "Default": "abc" },
          "blarg" : { "Type" : "String", "Default": "quux" }
          }
        }'''
        temp = [dict(id=4, template=templ, files='{}')]
        engine.execute(raw_template.insert(), temp)

        user_creds = utils.get_table(engine, 'user_creds')
        user = [dict(id=5, username='testuser', password='notthis',
                     tenant='mine', auth_url='bla',
                     tenant_id=str(uuid.uuid4()),
                     trust_id='',
                     trustor_user_id='')]
        engine.execute(user_creds.insert(), user)

        event = utils.get_table(engine, 'event')
        engine.execute(event.delete())
        stack = utils.get_table(engine, 'stack')
        engine.execute(stack.delete())
        stack_ids = ['967aaefb-152e-405d-b13a-35d4c816390a',
                     '9e9deba9-a303-4f29-84d3-c8165647c47b',
                     '9a4bd1ec-8b21-46cd-964a-f66cb1cfa2fd']
        parameters = '{"parameters": {"foo": "test"}}'
        data = [dict(id=ll_id, name='fruity',
                     raw_template_id=temp[0]['id'],
                     user_creds_id=user[0]['id'],
                     username='testuser', disable_rollback=True,
                     parameters=parameters)
                for ll_id in stack_ids]

        engine.execute(stack.insert(), data)
        return data

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/137223

Changed in heat:
assignee: nobody → Jason Dunsmore (jasondunsmore)
status: New → In Progress
Revision history for this message
OpenStack Infra (hudson-openstack) wrote :

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

Changed in heat:
assignee: Jason Dunsmore (jasondunsmore) → Visnusaran Murugan (visnusaran-murugan)
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Change abandoned on heat (master)

Change abandoned by Jason Dunsmore (<email address hidden>) on branch: master
Review: https://review.openstack.org/137223

Angus Salkeld (asalkeld)
Changed in heat:
importance: Undecided → High
milestone: none → kilo-2
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix merged to heat (master)

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

commit d69408e18a02bdd2e27af685a912066af7443863
Author: Visnusaran Murugan <email address hidden>
Date: Mon Dec 15 18:43:51 2014 +0530

    RowProxy replaced with update query to set db attributes

    Read-only RowProxy used to alter template data. Error
    not caught for lack of _pre_upgrade and _check validation.
    Using an update query to alter attributes and also
    adding validation scripts for 037, 041 and 043 database
    migration scripts.

    Change-Id: Ie3f122ed155ebb6aaa5007918cd9e121371749e4
    Closes-Bug: #1396313

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.