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?
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.
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 ?
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 -
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 -
On prem -
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>
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>
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,
@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.