Get hands-on experience with 20+ free Google Cloud products and $300 in free credit for new customers.

IllegalArgumentException reading property set

Documentation states that "Property set files support the same syntax as Java properties files":

- https://cloud.google.com/apigee/docs/api-platform/cache/property-sets#property-set-files

But Apigee X fails (IllegalArgumentException) when the key contains curly braces (example: "/users/{id}").

Properties file (config.properties):

 /users=a
 /users/{id}=b

AssignMessage policy, set the config-key flow variable to "/users/{id}":

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<AssignMessage continueOnError="false" enabled="true" name="AM-set-config-key">
    <DisplayName>AM-set-config-key</DisplayName>
    <AssignVariable>
        <Name>config-key</Name>
        <Value>/users/{id}</Value>
    </AssignVariable>
</AssignMessage>

AssignMessage policy, read the value from the property set using config-key as key:

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<AssignMessage continueOnError="false" enabled="true" name="AM-get-config-value">
    <DisplayName>AM-get-config-value</DisplayName>
    <AssignVariable>
        <Name>config-value</Name>
        <PropertySetRef>config.{config-key}</PropertySetRef>
    </AssignVariable>
</AssignMessage>

Error:

{"fault":{"faultstring":"Illegal propertyset key {} [config.\/users\/{id}]","detail":{"errorcode":"Bad Request"}}}
error.class: java.lang.IllegalArgumentException

Also tried with a JavaScript policy, same error:

print(context.getVariable('propertyset.config./users/{id}'));

Also tried with a standalone Java 8 application (outside Apigee). It worked fine as far curly braces in keys are valid in Java:

Reader reader = new FileReader("config.properties");
Properties properties = new Properties();
properties.load(reader);
System.out.println(properties.getProperty("/users/{id}")); // output: "b"

Is it a bug? Any workaround?

test-rev5-2021-03-25.zip

0 8 555
8 REPLIES 8