Quick question... I'd like to pass back a 502 in cases where the gateway cannot route to a backend service. For example, if the backend is down, I want the policy to return 502 vs. a 500 error. I had policy in place for this, but it doesn't seem to kick in as i expect. I always get back a "Policy Falsified" exception on the routing assertion.
How can I trap this and handle it properly? Here is a snippet of my routing:
Thank you for your enquiry. The Policy snippet looks good, is there any clue in the audit logs as to what is failing on the routing assertion?
Have you ran the policy through the service debugger to understand the flow?
Christopher ClarkCA APIM Support
Instead of setting the error values , perhaps it would be easier to use the "Customize Error Response" Assertion to return the 502 and Bad Gateway text.
Thanks & Regards,
I think the problem here is that your Route assertion is within an "All assertions must evaluate to true" assertion. Once the route fails, the "All.." assertion fails, and your policy as a whole fails. Maybe try something like this
When I put an invalid URL in the Route assertion I get back the customized error response. With this policy logic, either the Route assertion is successful, or the Customize and Stop assertions within the "All..." assertion are executed. I suggest you put the audit assertion outside of(before) the "At least one..." assertion.
Hello acalbazana ,
The structure is fine, but the Stop Processing assertion will fail the policy.
The stop processing assertion or raise error assertion are usually used to raise the error again, to trigger the Customize error response assertion.
ie. if you don't use customize error response, you need to use Return template assertion instead of the Stop Processing assertion to return http code 502 and custom error message.
Thanks. Got his covered. Bill's recommendation was on point. The "All.." assertion allowed the route assertion to short-circuit my error handling.