KB Article #176318

Make undefined API Gateway message properties expand to an empty string instead of [invalid field]

Problem

How do you make undefined API Gateway message properties expand to an empty string instead of [invalid field]?

Resolution

In older versions of API Gateway, the default behavior was to treat a property from the message whiteboard that was not defined as an empty string and many policies were written expecting this behavior. Since 7.x, the default behavior has been to expand an empty property as [invalid field] to allow people to distinguish undefined values from empty strings, but this behavior may be undesirable when a policy set has been upgraded from older versions and refactoring the policies to account for the changed behavior is impractical.


You can return to the old (6.x) behavior and make undefined message properties expand to empty strings by adding the following lines to <install>/apigateway/conf/jvm.xml You may need to create the jvm.xml file if it does not already exist. If a jvm.xml does exist, you should just add the VMArg element to the inside of the ConfigurationFragment element in the existing file.


<ConfigurationFragment>
<VMArg name="-DExpandMissingAttributeBehaviour=EMPTY_STRING"/>
</ConfigurationFragment>


You can also take advantage of the fact that selector expressions are interpreted as JUEL (Java Unified Expression Language) to construct an expression like: ${empty my.parameter ? my.parameter : ""}