Skip to content

Commit

Permalink
raise incompletedatabag exception if units empty
Browse files Browse the repository at this point in the history
  • Loading branch information
carlcsaposs-canonical committed Jun 29, 2023
1 parent 248c87a commit 8d790a5
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/relations/deprecated_shared_db_database_provides.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,14 @@ class _RemoteUnitDatabag(remote_databag.RemoteDatabag):

def __init__(self, relation: ops.Relation) -> None:
# Subordinate charms can only access principal unit's databag
self._app_name = relation.app.name
self._endpoint_name = relation.name
if not relation.units:
raise remote_databag.IncompleteDatabag(app_name=self._app_name, endpoint_name=self._endpoint_name)
assert len(relation.units) == 1
# Principal unit
remote_unit = relation.units.copy().pop()
dict.__init__(self, relation.data[remote_unit])
self._app_name = relation.app.name
self._endpoint_name = relation.name


class _RelationBreaking(Exception):
Expand Down

0 comments on commit 8d790a5

Please sign in to comment.