jkevan commented on a change in pull request #365:
URL: https://github.com/apache/unomi/pull/365#discussion_r752976890



##########
File path: 
services/src/main/java/org/apache/unomi/services/impl/rules/RulesServiceImpl.java
##########
@@ -393,6 +408,11 @@ public void setRule(Rule rule) {
                 definitionsService.extractConditionBySystemTag(condition, 
"eventCondition");
             }
         }
+        List<Action> actions = rule.getActions();
+        if (actions == null || actions.isEmpty()) {
+            logger.warn("rule {} won't be saved as it contains no action", 
rule.getItemId());
+            return;
+        }

Review comment:
       We need to check if the rule is disabled here, in case it is disabled we 
could authorize the persitence even if there is no action.
   It's like a draft rule.
   
   Also it could be interesting to force the disable but save anyway in case of 
no action to avoid user loosing there work in case they are using some sort of 
UI to build the rule, they may not be aware that the rule is not saved at the 
end.
   
   Also in case we still want to not save the rule, then we should crash an 
Exception or a validation error message. Because the setRule didn't do the 
expected behavior.
   I think force disabling the rule and save anyway would be the more easy to 
do. and more logic considering the rest of the fix




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to