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

DefaultFaultRule not triggered for HTTP 405 error at proxy endpoint REQ_HEADERS_PARSED

I have an api proxy with the default fault rule configured and alwaysEnforce set to false. The default fault rule gets executed for http 404 errors, or if there is a raise fault configured from the api proxy flows.

One of the requests with a file upload (coming from a UI) is failing due to file size being very large. Apigee throws 405 error in this case. The UI expects CORS headers to be part of the response and I set those in the default faultrule while sending the error response.

This the default faultrule configuration in the proxy endpoint

	<DefaultFaultRule name="DefaultFaultRule">
        <AlwaysEnforce>true</AlwaysEnforce>
        <Step>
            <FaultRules/>
            <Name>AddCORSHeaders</Name>
        </Step>
        <Step>
            <FaultRules/>
            <Name>ReturnGenericError</Name>
        </Step>
        <AlwaysEnforce>false</AlwaysEnforce>
    </DefaultFaultRule>

Trace file attached.

Trace shows error.state=REQ_HEADERS_PARSED. How do you capture this to trigger the fault rule?

However, I noticed that the default fault rule does not get triggered in the above scenario. Any pointers on how to handle this?

[Using Apigee private cloud 4.18.05.06]

Solved Solved
0 4 1,637
1 ACCEPTED SOLUTION

According to the docs:

A DefaultFaultRule acts an exception handler for any error that is not explicitly handled by another FaultRule.

If you want the DefaultFaultRule steps to always execute then set:

<AlwaysEnforce>true</AlwaysEnforce>

In your snippet you have <AlwaysEnforce>true</AlwaysEnforce> at the top and <AlwaysEnforce>false</AlwaysEnforce> at the bottom which I suspect is what Apigee is interpreting the value to be.

See docs: https://docs.apigee.com/api-platform/fundamentals/fault-handling#creatingfaultrules-creatingadefault...

View solution in original post

4 REPLIES 4