BeanShell error in transform

I have a simple transform that defines a single input value and converts it if applicable.

The problem part of the transform is shown below:

<?xml version='1.0' encoding='UTF-8'?>
<!DOCTYPE Rule PUBLIC "sailpoint.dtd" "sailpoint.dtd">
<Rule name="..." type="Transform">
  <Description>...</Description>
  <Signature returnType='Object'>
    <Inputs>
      <Argument name='input' type='Object'>
        <Description>
          The input data passed into the transform.
        </Description>
      </Argument>
    </Inputs>
  </Signature>
  <Source><![CDATA[
    import org.apache.commons.lang.StringUtils;

    String convert(String timestamp) throws Exception { /**/ }

    String s = StringUtils.trimToNull((String)input);
    if (s == null) {
        return null;
    }

    return convert(s);
  ]]></Source>
</Rule>

When the input is null, the UI in isc suggests the cast (String)input threw an exception.

I am not a Java developer, but this is perfectly valid as far as I know. The following compiles and runs just fine in both regular Java and BeanShell:

Object o = null;
String s = (String)o;

And StringUtils.trimToNull() accepts null input anyway.

Does anyone know what I am missing?

hello! i can’t answer this specific question, but just to clarify, this is not a transform but a rule.

Your usecase can be done with transform rather than use rule.

What you want to achieve exactly ?

Hi,
No, the value passed into the transform is most certainly input as that is what I named it.

It works perfectly when a value exists.

The timestamp variable is the parameter to the function that contains the custom logic, I omitted it because it works and has no relevance.

Sorry,
There is a lot of logic inside the function which was omitted as it has no relevance.

That logic is not feasible in a transform.

1 Like

(Sorry I misread your code earlier)

Probably transform is not injecting the variable input when it’s null or has no value.

Put this

String s = StringUtils.trimToNull((String)input);
if (s == null) {
    return null;
}

in

try{
   String s = StringUtils.trimToNull((String)input);
   if (s == null) {
      return null;
   }
   return convert(s);
} catch(Exception e){
   return null;
}

I just spoke to a technical advisor who noticed what she was sure was the problem.

Apparently the product doesn’t like transforms that return null, so the suggested fix was to leave everything else as is, and return an empty string.

I am submitting an update for a review and deployment, I’ll post an update once I test.

Thanks for the help!

1 Like