Wednesday, January 6, 2016

CA API Gateway Route via Assertion Not Evaluating False

I was composing a CA API Gateway policy that was not falling out of an "All assertions must evaluate to true" block when the invocation of a service resulted in a fault. Since a fault was being thrown, I expected the assertion to evaluate to false; however, it was evaluated as true.

CA API Gateway Policy
When the endpoint was invoked, the policy would execute the "Route via" assertion and continue processing to the following "Add Audit Details" assertion as depicted in the following log.

2016-01-06T14:25:30.134-0500 INFO 10769 com.l7tech.server.policy.assertion.ServerAuditDetailAssertion: -4: Invoking service
2016-01-06T14:25:30.134-0500 INFO 10769 com.l7tech.server.policy.assertion.ServerHttpRoutingAssertion: 4047: Request is a context variable; using POST
2016-01-06T14:25:30.134-0500 INFO 10769 com.l7tech.server.policy.assertion.ServerAuditDetailAssertion: -4: Invoked service

The service that was invoked was configured to return a fault, and one would expect that if a "Route via" assertion returns a fault, this would result in a false condition. Therefore, control would fall out of the first "All assertions must evaluate to true" assertion and move on to the next "All assertions must evaluate to true" block.

Upon investigation, I discovered a somewhat confusing checkbox that solved the issue.

Pass through SOAP faults with error status 500 checkbox marked
In the HTTP(S) Routing Properties (double click the Route via assertion) window, on the Other tab, in the Assertion Outcome frame, there is a checkbox entitled, "Pass through SOAP faults with error status 500."

At first glance, one might interpret this as whatever fault is thrown by the invoked service, pass that fault right on through to the consumer. In fact, what this means is that the assertion will completely ignore that fault by evaluating the assertion as true and continue processing the next assertion.

After unmarking this checkbox, the assertion then evaluated to false, as expected.

Pass through SOAP faults with error status 500 checkbox unmarked

2016-01-06T14:26:44.623-0500 INFO 10684 com.l7tech.server.policy.assertion.ServerAuditDetailAssertion: -4: Invoking service
2016-01-06T14:26:44.623-0500 INFO 10684 com.l7tech.server.policy.assertion.ServerHttpRoutingAssertion: 4038: Downstream service returned status (500). This is considered a failure case.