diff --git a/src/relations/async_replication.py b/src/relations/async_replication.py index 39543480fa..320beeb487 100644 --- a/src/relations/async_replication.py +++ b/src/relations/async_replication.py @@ -487,7 +487,7 @@ def _on_async_relation_changed(self, event: RelationChangedEvent) -> None: def _on_async_relation_departed(self, event: RelationDepartedEvent) -> None: """Set a flag to avoid setting a wrong status message on relation broken event handler.""" # This is needed because of https://bugs.launchpad.net/juju/+bug/1979811. - if event.departing_unit == self.charm.unit or self.charm._peers is None: + if event.departing_unit == self.charm.unit and self.charm._peers is not None: self.charm._peers.data[self.charm.unit].update({"departing": "True"}) def _on_async_relation_joined(self, _) -> None: