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
I have created a custom condition that doesn't require request object and works fine.
But issue is a runtime error occurs when by mistake a user adds a flag with a condition that requires requests, making my code to fail at runtime with request is not required.
For instance using flags in celery tasks.
At the moment am doing this hack
``
from flags import conditions
def patched_check(self, **kwargs):
if self.fn is not None:
try:
return self.fn(self.value, **kwargs)
except Exception as e:
logger.exception(f"Error checking condition {self.condition}: {e}")
return False
return False
Apply the monkey patch
Condition.check = patched_check
``
Is this something that should be contributed back to support exceptions and just return false
I have created a custom condition that doesn't require request object and works fine.
But issue is a runtime error occurs when by mistake a user adds a flag with a condition that requires requests, making my code to fail at runtime with request is not required.
For instance using flags in celery tasks.
At the moment am doing this hack
``
from flags import conditions
def patched_check(self, **kwargs):
if self.fn is not None:
try:
return self.fn(self.value, **kwargs)
except Exception as e:
logger.exception(f"Error checking condition {self.condition}: {e}")
return False
return False
Apply the monkey patch
Condition.check = patched_check
``
Is this something that should be contributed back to support exceptions and just return false
i.e
flag_enabled("feature_flag", handle_exception=True)
The text was updated successfully, but these errors were encountered: