Make the check more efficient if a trigger dictionary is passed in and
it already contains type attribute.
@@ -124,12 +124,17 @@ def validate_trigger_payload(trigger_type_ref, payload, throw_on_inexistent_trig
if not trigger_type_ref:
return None
+ # NOTE: Due to the awful code in some other places we also need to support a scenario where
+ # this variable is a dictionary and contains various TriggerDB object attributes.
if isinstance(trigger_type_ref, dict):
+ if trigger_type_ref.get('type', None):
+ trigger_type_ref = trigger_type_ref['type']
+ else:
trigger_db = triggers.get_trigger_db_by_ref_or_dict(trigger_type_ref)
if not trigger_db:
- # Corresponding TriggerDB not found, likely a corrupted database,
- # skip the validation.
+ # Corresponding TriggerDB not found, likely a corrupted database, skip the
+ # validation.
return None
trigger_type_ref = trigger_db.type
