You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
the Framework._event_context var is used by the framework to determine whether it should be validating relation data access and for example raise if a nonleader unit is trying to read data only a leader can access. _event_context is only set during _reemit, that is, when an event is actually being processed by the charm.
This causes the following confusing situation during testing:
(supposing we don't have leadership)
classMyCharm:
def__init__():
relation.data[self.app] # no problem: false positive
...
def_on_foo_event(self, _):
relation.data[self.app] # problem
Note that this issue also (very probably) causes inconsistent tracebacks in production.
A possible solution could be to enter the event context before the charm is initialized if we are testing (and set it to some "not-a-real-event" string as, at the point in time when we initialize the charm, we don't yet necessarily know what event we'll be emitting on it)
The text was updated successfully, but these errors were encountered:
the
Framework._event_context
var is used by the framework to determine whether it should be validating relation data access and for example raise if a nonleader unit is trying to read data only a leader can access._event_context
is only set during_reemit
, that is, when an event is actually being processed by the charm.This causes the following confusing situation during testing:
(supposing we don't have leadership)
Note that this issue also (very probably) causes inconsistent tracebacks in production.
A possible solution could be to enter the event context before the charm is initialized if we are testing (and set it to some "not-a-real-event" string as, at the point in time when we initialize the charm, we don't yet necessarily know what event we'll be emitting on it)
The text was updated successfully, but these errors were encountered: