Policies in FaultRules are not executing in sequence

Not applicable

Policies in faultRules are not exeuting in sequence.

EX:

1. AssgnMessage

2. HandlRespone

3. TemplaterMappingJSON

Above is the order of policies in FaultRules. My concern is HandleResponse policy is executing after TemplateMappinJson Policy.

0 10 474
10 REPLIES 10

@Kodandapani - this is not the behaviour of FaultRules. All policies execute in order that they are defined.

Possible to share us the xml for your FaultRules and let us know how you are coming to the conclusion that one is executing before the other?

Not applicable
<FaultRules>
	<FaultRule name="faultRules"> 
		<Step>
			<Name>AssigMessage</Name>
		</Step>
		<Step>
			<Name>HandlRespone</Name>
		</Step>
		<Step>
			<Name>TemplaterMappingJSON</Name>
		</Step>
	</FaultRule>    
</FaultRules>

Not applicable

<FaultRules> <FaultRule name="faultRules"> <Step> <Name>AssigMessage</Name> </Step> <Step> <Name>HandlRespone</Name> </Step> <Step> <Name>TemplaterMappingJSON</Name> </Step> </FaultRule> </FaultRules>

Thanks - so how are you coming to the conclusion that TemplaterMappingJSON executes before HandlRespone? Possible to run Apigee trace functionality when you send a request to your API?

I opened the trace and verified the flow of execution. And observed that policies are not executing sequentially

@Kodandapani , Are you sure same API proxy revision has been deployed to environment that you see in Develop tab & Trace Tab ?

Yes, I am seeing same revision

akoo
Participant V

Hello Kodandapani,

Could you please attach the trace file? You can download the trace file in the trace tool. We can then inspect this on our end.

Thanks so much,

-Alex

Hello @Alex Koo and @Ozan Seymen

I have had a wierd issue in the last couple of days. For 503 error, the policy sequence is not maintained. I have to change the target host which doesn't exist to test the scenarios. I have javascript where I am handling all the errors. I have a feeling that the sequence is not maintained because of the javascript. Although I have checked that async="false" is set javascript. Here is the code I have used in target default as

<FaultRules>
        <!-- standard fault handling -->
        <FaultRule name="FaultHandling">
            <Step>
                <Name>APICommon_AM_AddCORS</Name>
            </Step>
            <Step>
                <Name>APICommon_JS_ParseTargetFault</Name>
            </Step>
            <Step>
                <Name>APICommon_JS_FormatTimeStamp</Name>
            </Step>
        </FaultRule>
    </FaultRules>
    <DefaultFaultRule name="all">
        <AlwaysEnforce>true</AlwaysEnforce>
        <Step>
            <Name>APICommon_RF_ErrorJson</Name>
            <Condition>errorResponseType == "json" and errorFormattingNeeded == "Y"</Condition>
        </Step>
        <Step>
            <Name>APICommon_RF_ErrorXml</Name>
            <Condition>errorResponseType == "xml" and errorFormattingNeeded == "Y"</Condition>
        </Step>
    </DefaultFaultRule>

I have made the calls with the same request from post and trace these calls in apigee and here is the policy execution sequence as displayed in apigee edge.

I am not able to figure out this behavior, please help me out here.

4837-trace.png

Thanks,

Krish

Hello @Krish,

Thanks for the information. I had a few comments:

1) If you wouldn't mind, could you please create a separate question for your exact question? This will help others who encounter a similar issue such as your's.

2) In the new question, could you please include a trace file so we can see the sequence? You can download the trace file in the trace tool. We can then inspect this on our end.

3) We do not recommend modifying async="false" attribute in your policies, as it's not representative of async functionality as most API proxy developers believe it to be. You can just leave that as false (default value).