Red Hat Bugzilla – Bug 1023126
Saving Guided Rule with uninitialized field values causes errors after reopening
Last modified: 2014-08-06 16:19:46 EDT
Description of problem:
Leaving field values uninitialized doesn't seem to be invalid. There is no UI warning. If the rule is saved in this state, the generated DRL source will have syntax errors and the rule will not reopen correctly in Guided Editor. Some elements will appear different than before saving, some elements may disappear completely.
Version-Release number of selected component (if applicable):
Steps to Reproduce:
1. open no NINJAs rule in mortgages project
2. add amount and explanation fields to LoanApplication [app]
3. set "equal to" operators
4. bring up the input boxes for literal values, don't type any values
5. click into input box for amount field and then to explanation input
When amount input box loses focus, "0" value appears automatically. Looks like a sensible default value. The explanation input stays empty, which also makes sense -- the author may want to test the field against en empty string. However, when you switch to Source tab you will see:
app : LoanApplication( == null , == "null" )
You may miss this and save and close the rule. When you reopen it you get modal error message "Could not find the type for variable app". The rule will appear with errors in RHS and different LHS, see attached screenshots.
Saving the rule should never break it. Either the save could be denied if validation fails so the user would be forced to save it in a valid state, or better, the invalid/incomplete parts of the rule should be ignored. In that case unfinished parts would be lost after closing the editor but the rule would open in a correct state without losing or modifying any elements that were valid before saving.
Compare the screenshots of GRE before and after save carefully. Not only that "There is a LoanApplication [app] with:" element is crippled, the second conditional element "The following does not exist: There is an IncomeSource" is missing completely.
Created attachment 815850 [details]
Guieded Editor with uninitialized fields before save
Created attachment 815851 [details]
Source generated from uninitialized fields
Created attachment 815853 [details]
Guieded Editor after reopening the rule
Two improvements have been made:
(1) Don't render incomplete constraints when building DRL
(2) Explicitly set initial value when adding literals (which should have been happening anyway but was bugged).
Michael, thank you for this fine fix, it makes GRE more foolproof and reliable.