Why does Apigee appear to add additional parentheses to my condition in my flow?

Not applicable

I have a Flow defined such that upon invalid query parameters, Apigee will raise a fault and respond to the client rather than letting the request continue onward to the server.

For my following 'PUT' (update) endpoint, I would it like it so at least one of the four possible query parameters is included in the request. Otherwise there is nothing to do on the target endpoint, so raise my fault.

My flow is defined like the following:

<Flow name="validateQueryParameters">
	<Condition>(request.verb equals "PUT") and ((proxy.pathsuffix equals "/users/{user_id}/resources/{resource_id}") or (proxy.pathsuffix equals "/users/{user_id}/resources/{resource_id}/")) and (((proxy.queryparam.myParam1 is null) or (proxy.queryparam.myParam1 is empty)) and ((proxy.queryparam.myParam2 is null) or (proxy.queryparam.myParam2 is empty)) and ((proxy.queryparam.myParam3 is null) or (proxy.queryparam.myParam3 is empty)) and ((proxy.queryparam.myParam4 is null) or (proxy.queryparam.myParam4 is empty)))</Condition>
	<Description>Ensures user provided necessary query parameters for</Description>
	<Request>
		<Step>
			<Name>fault_invalid_query_param</Name>
		</Step>

	</Request>

	<Response/>

</Flow>

Which if you inspect carefully, you will notice that there are three main parts/conditions that I have and-ed together. It should be a PUT request, it should be going to my /users/{..}/resources/{..} endpoint (with or without that last forward slash, "/")

However, upon tracing a flow, I always get a 'Failed' result for this condition. Upon inspecting the properties section in the trace, you can see that Apigee automatically changes my parentheses so that the condition that it actually checks is the following:

((request.verb equals "PUT") and (((proxy.pathsuffix equals "/users/{user_id}/resources/{resource_id}") or (proxy.pathsuffix equals "/users/{user_id}/resources/{resource_id}/")) and (((proxy.queryparam.myParam1 equals null) or (proxy.queryparam.myParam1 equals empty)) and (((proxy.queryparam.myParam2 equals null) or (proxy.queryparam.myParam2 equals empty)) and (((proxy.queryparam.myParam3 equals null) or (proxy.queryparam.myParam3 equals empty)) and ((proxy.queryparam.myParam4 equals null) or (proxy.queryparam.myParam4 equals empty)))))))

It looks like Apigee automatically adds a parenthesis to the left side of MOST of the opening parentheses after each "and", but then to account for these Apigee throws a bunch of closing parentheses to the very end.

Is this a bug in Apigee?

If so, is there a way I can rearrange my condition in such a way that it works for the time being until Apigee fixes this bug?

Thanks

0 2 399
2 REPLIES 2

Not applicable

Hi @cdillinger , I have used complex conditions but never saw the above issue on 15.04 but may be some combinations of and , or and ) is causing this issue .

I can check with your snippet and raise a bug if thats the case .

Meanwhile , you can just have a condition on PUT and handle the queryparam checks in a javascript policy and raise a fault accordingly .

BTW are you seeing this on cloud or private cloud ?

Not applicable

I have reviewed your conditions and the generated conditions and they appear to be logically identical.

Can you examine your test case and see if indeed all the params you are checking for are indeed populated and all other conditions are matching (or not) as expected in the test scenario?