Comment 5 for bug 1914415

Revision history for this message
John A Meinel (jameinel) wrote :

To try and distill issue 175, I believe the issue is that Relation.app is set by:
https://github.com/canonical/operator/blob/master/ops/model.py#L642

Which iterates the known units, and then pulls the application from those units.

However, in events like relation-created and relation-changed, there may be data associated with the application, and not with any units. Thus Relation.units has an empty list.
Juju itself is setting JUJU_REMOTE_APP as an environment variable during those events.

Which should be populated on the event object:
https://github.com/canonical/operator/blob/master/ops/main.py#L154

So I might be wrong. I was thinking about Relation.app (which has a known bug) not RelationEvent.app (which should be properly populated).

Unless it is:
https://github.com/canonical/operator/blob/master/ops/model.py#L684

which seems to only populate RelationData[app] if *Relation.app* is set.