Skip to content

"'CharmRelation' object is not subscriptable" errors #414

@Vultaire

Description

@Vultaire

Hello,

At least one of our charms (likely others, but I've only tested one thus far) is no longer able to run libjuju-based tests without modification.

It seems that commit 4d2895a introduced changes where data which was formerly in dictionaries is now in CharmRelation objects (as seen in e.g. juju/client/_definitions.py, AddRelationResults class). This seems to be breaking things internally to libjuju.

Here's an example of pytest output upon trying to call add_relation():

        for ubuntu_unit in ['ubuntu', 'ubuntu-checksum']:
            await nrpe_app.add_relation(
                'general-info',
>               '{}-{}:juju-info'.format(ubuntu_unit, release)
            )

tests/functional/test_hwhealth.py:94: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
/usr/lib/python3.6/asyncio/coroutines.py:110: in __next__
    return self.gen.send(None)
.tox/functional/lib/python3.6/site-packages/juju/application.py:103: in add_relation
    return await self.model.add_relation(local_relation, remote_relation)
/usr/lib/python3.6/asyncio/coroutines.py:110: in __next__
    return self.gen.send(None)
.tox/functional/lib/python3.6/site-packages/juju/model.py:1192: in add_relation
    for app, data in result.endpoints.items()]
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

.0 = <dict_itemiterator object at 0x7f76939210e8>

    specs = ['{}:{}'.format(app, data['name'])
>            for app, data in result.endpoints.items()]
E   TypeError: 'CharmRelation' object is not subscriptable

.tox/functional/lib/python3.6/site-packages/juju/model.py:1192: TypeError

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions