diff --git a/django_forms_workflows/workflow_builder_views.py b/django_forms_workflows/workflow_builder_views.py index e666591..d2cc95e 100644 --- a/django_forms_workflows/workflow_builder_views.py +++ b/django_forms_workflows/workflow_builder_views.py @@ -704,12 +704,26 @@ def is_valid_field_name(value): f"Notification rule {rule_index} references workflow stage ID {stage_id}, but that stage is not present in the submitted builder graph." ) + notify_submitter = rule_data.get("notify_submitter") + notify_stage_assignees = rule_data.get("notify_stage_assignees") + notify_stage_groups = rule_data.get("notify_stage_groups") + + for flag_name, flag_value in ( + ("notify_submitter", notify_submitter), + ("notify_stage_assignees", notify_stage_assignees), + ("notify_stage_groups", notify_stage_groups), + ): + if flag_value is not None and not isinstance(flag_value, bool): + add_error( + f"Notification rule {rule_index} field '{flag_name}' must be a boolean." + ) + has_recipients = bool( - rule_data.get("notify_submitter") + (notify_submitter is True) or rule_data.get("email_field") or rule_data.get("static_emails") - or rule_data.get("notify_stage_assignees") - or rule_data.get("notify_stage_groups") + or (notify_stage_assignees is True) + or (notify_stage_groups is True) or (rule_data.get("notify_groups") or []) ) if not has_recipients: @@ -2629,7 +2643,12 @@ def graph_action_ids(graph): rule_id_text = str(raw_rule_id).strip() if not rule_id_text.isascii() or not rule_id_text.isdigit(): raise BuilderValidationError("Invalid notification rule identifier.") - normalized_rule_id = int(rule_id_text) + try: + normalized_rule_id = int(rule_id_text) + except ValueError as exc: + raise BuilderValidationError( + "Invalid notification rule identifier." + ) from exc if not 0 < normalized_rule_id <= 2**63 - 1: raise BuilderValidationError("Invalid notification rule identifier.") rule_obj = existing_notification_rules.get(normalized_rule_id)