Default fault rule is executed even when another policy raised a fault. How to stop this?

Not applicable

Default fault rule worked in the case where no fault was able to catch the exception. But it is also executing when another fault is raised. Even when <AlwaysEnforce> is false.

Attached is the screenshot of the trace. Below is how I am applying the default rule

<TargetEndpoint name="something">
    <Description/>
    <FaultRules/>
    <DefaultFaultRule name="fault-rule">
        <Step>
            <Name>ReturnGenericError</Name>
        </Step> 
        <AlwaysEnforce>false</AlwaysEnforce> 
    </DefaultFaultRule>
    <Flows/>

	...

How to stop this?

0 12 4,895
12 REPLIES 12

Dear @Arun Kumar Reddy ,

Remove AlwaysEnforce . That should solve problem.

It didn't. That tag is false anyway.

I tried removing it completely also. It still being executed.

@Anil Sagar

Is there any solution or is it a bug in APIGEE?

we are using this because we are unable to catch 503 error even after adding it in success.codes values.

If either of these work, our issue is resolved.

@Arun Kumar Reddy , It should work. Can you test same with simple proxy & post the result ?

Not applicable

Attached is a sample proxy where a request which gives 404 error is being caught and raised by a fault policy and also being executed in default fault rule.

Below is a sample valid request -

http://arunisme-test.apigee.net/v1/weather/forecastrss

Is there any updates on this even i am having the same issue.Even if another raise fault is invoked(with continueonerror being false) still the default fault rule gets executed..Any suggestions on this

Arun, your TargetEndpoint does not set <AlwaysEnforce>false</AlwaysEnforce>. Did you try adding that?

    <DefaultFaultRule name="fault-rule">
        <Step>
            <Name>ReturnGenericError</Name>
        </Step>
    </DefaultFaultRule>

Hi @sgilson, @Vijay Muralitharan, @Arun Kumar Reddy,

I just tested this in Cloud (150930.01) & On-Prem (4.14.07.00). The On-Prem works like a charm. I have also attached snapshots of both.

@Anil Sagar,

This looks to be a bug in Cloud (150930.01). Please address this.

Cloud -

1608-capture-cloud.png

On prem -

1609-capture-on-prem.png

Dear @Arun Kumar Reddy , @Abhishek Subramanya ,

It works as expected on cloud too. Please find attached proxy & details.

Only , one raise fault is executed on default , Always Enforce "false"

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<ProxyEndpoint name="default">
    <Description/>
    <FaultRules>
        <FaultRule name="invalid_key_rule">
            <Step>
                <Name>invalidKey</Name>
            </Step>
            <Condition>(fault.name = "FailedToResolveAPIKey")</Condition>
        </FaultRule>
    </FaultRules>
    <DefaultFaultRule name="fault-rule">
        <Step>
            <Name>ReturnGenericError</Name>
        </Step>
        <AlwaysEnforce>false</AlwaysEnforce>
    </DefaultFaultRule>
    <PreFlow name="PreFlow">
        <Request>
            <Step>
                <Name>Verify-API-Key-1</Name>
            </Step>
        </Request>
        <Response/>
    </PreFlow>
    <PostFlow name="PostFlow">
        <Request/>
        <Response/>
    </PostFlow>
    <HTTPProxyConnection>
        <BasePath>/v1/weatherfault</BasePath>
        <VirtualHost>default</VirtualHost>
        <VirtualHost>secure</VirtualHost>
    </HTTPProxyConnection>
    <RouteRule name="default">
        <TargetEndpoint>default</TargetEndpoint>
    </RouteRule>
</ProxyEndpoint>

1610-screen-shot-2015-12-04-at-120619-pm.png

Both, Fault rule & default fault rule is executed when , Always Enforce "true"

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<ProxyEndpoint name="default">
    <Description/>
    <FaultRules>
        <FaultRule name="invalid_key_rule">
            <Step>
                <Name>invalidKey</Name>
            </Step>
            <Condition>(fault.name = "FailedToResolveAPIKey")</Condition>
        </FaultRule>
    </FaultRules>
    <DefaultFaultRule name="fault-rule">
        <Step>
            <Name>ReturnGenericError</Name>
        </Step>
        <AlwaysEnforce>true</AlwaysEnforce>
    </DefaultFaultRule>
    <PreFlow name="PreFlow">
        <Request>
            <Step>
                <Name>Verify-API-Key-1</Name>
            </Step>
        </Request>
        <Response/>
    </PreFlow>
    <PostFlow name="PostFlow">
        <Request/>
        <Response/>
    </PostFlow>
    <HTTPProxyConnection>
        <BasePath>/v1/weatherfault</BasePath>
        <VirtualHost>default</VirtualHost>
        <VirtualHost>secure</VirtualHost>
    </HTTPProxyConnection>
    <RouteRule name="default">
        <TargetEndpoint>default</TargetEndpoint>
    </RouteRule>
</ProxyEndpoint>

1611-screen-shot-2015-12-04-at-120540-pm.png

Fault rules, Default Fault rule will be executed only if there is an exception / error in proxy flow.

It works like below,

A fault has been raised in Proxy Flow,

  • Are fault rules defined & condition matches - Execute the policies defined matched fault rule
  • Are fault rules defined & condition matches, Default Fault rule exist with Always Enforce "True" - Execute the policies defined matched fault rule, Execute the policies in default fault rule
  • Are fault rules defined & condition matches, Default Fault rule exist with Always Enforce "false" - Execute the policies defined in matched fault rule only
  • Are fault rules defined & condition doesn't match , Default Fault rule exist with Always Enforce "True/ False "- Execute the policies defined in default fault rule only
  • Are fault rules undefined, Default Fault rule exist with Always Enforce "True/ False "- Execute the policies defined in default fault rule only

@Anil Sagar, please find the attached proxy which is showing the discrepancy. I am using the same only which @Arun Kumar Reddy uploaded some time ago. Please let us know what could be the reason for difference in behavior.

@Abhishek Subramanya , Proxy attached by @Arun Kumar Reddy has some issues. It does fault rules implementation in targetendpoint & uses assign message policy to set status code on request payload instead of response. Please check updated policy attached in this answer and let me know if you have any questions.