I am facing an ‘Unknown Error: Null’ in my Before Provisioning rule. In my rule, I do a null check on the account requests in my provisioning plan before moving on to my business logic, but this line (Line 245) seems to be the reason why i’m facing the error above.
Unfortunately, the complete code actually contains confidential client reference data thus I am unable to share it. However, I am able to share a short pseudo-code:
List accountRequests = null == plan.getAccountRequests() ? new ArrayList() : plan.getAccountRequests();
Identity identity = plan.getIdentity();
if (!accountRequests.isEmpty()) {
if (op.equals(AccountRequest.Operation.Modify)) {
if (identity != null) {
String deptAdidChange = identity.getStringAttribute("deptAdidChange");
if ((deptAdidChange.equalsIgnoreCase("true"))) {
//Create a new account request (with op = Create)
AccountRequest newAccReq = accountRequest.clone();
newAccReq.setOperation(ProvisioningPlan.AccountRequest.Operation.Create);
plan.add(newAccReq);
//Modify existing account request (with op = Disable)
accountRequest.setOperation(ProvisioningPlan.AccountRequest.Operation.Disable);
}
}
} else {
//Logic for other business flows
}
}
Our business requirement requires us to disable the current account request & add on a new account request (for account creation) and that is the portion where we are facing the error. We got SailPoint team to help extract our logs but it doesn’t give us much info either. Snippet of the logs:
By any chance, if the accountRequests value becomes null, then there is no way to check the null. So, it is better to check the null first and then use methods on the object reference.
Use below code once:
List accountRequests = plan.getAccountRequests();
Identity identity = plan.getIdentity();
if(null != accountRequests)
{
if (!accountRequests.isEmpty() && accountRequests.size()>=1) {
if (op.equals(AccountRequest.Operation.Modify)) {
if (identity != null) {
String deptAdidChange = identity.getStringAttribute(“deptAdidChange”);
if ((deptAdidChange.equalsIgnoreCase(“true”))) {
//Create a new account request (with op = Create)
AccountRequest newAccReq = accountRequest.clone();
newAccReq.setOperation(ProvisioningPlan.AccountRequest.Operation.Create);
plan.add(newAccReq);
//Modify existing account request (with op = Disable)
accountRequest.setOperation(ProvisioningPlan.AccountRequest.Operation.Disable);
}
}
} else {
//Logic for other business flows
}
}
Just wondering, for line 2 - if I were to put ‘plan.getAccountRequests()’ without the ‘null ==’ at the front, it wouldn’t return me a boolean, and the entire line will be erroneous wouldn’t it?
To confirm, did you attempt to check if the ProvisioningPlan is null before the execution of the code?
Another point to mention would be to add loggers in the code and print out some of the values in the rule to check what/where the error is originating from.
I would suggest to almost add the loggers after every line, printing out the variables are results to get a clear understanding of where it stops.
We have managed to resolve this error. The issue was with adding the account request directly to the plan in this line of code
plan.add(newAccReq);
Instead of this, we added the new account request to a new list that we created, and then went on to add the current account request to this list. From there, we set the list in our plan and the logic managed to work for a mover flow. The updated code is as follows:
List newAccountRequestList = new ArrayList();
newAccountRequestList.add(newAccReq);
.
.
.
plan.setAccountRequests(newAccountRequestList);