Raisefault policy does not populate variables set in AssignVariable tag

Hi All,

I have two policies in a shared flow. A javascript and a Raise Fault. I am trying to raise a fault based on a variable that is set in javascript. I want this shared flow to return a specific set of error values so I am using AssignVariable tag in the raise fault to populate these variables. Below is the policy XML.

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<RaiseFault async="false" continueOnError="false" enabled="true" name="Target_Fault">
    <DisplayName>Target_Fault</DisplayName>
    <Properties/>
    <FaultResponse>
        <AssignVariable>
            <Name>api.error.code</Name>
            <Value>1234</Value>
        </AssignVariable>
        <AssignVariable>
            <Name>api.error.message</Name>
            <Value>Invalid B2B Client ID</Value>
        </AssignVariable>
        <AssignVariable>
            <Name>api.error.info</Name>
            <Value>https://developers.myapi.com/errors/1234</Value>
        </AssignVariable>
        <AssignVariable>
            <Name>api.error.status</Name>
            <Value>401</Value>
        </AssignVariable>
        <AssignVariable>
            <Name>api.error.reason</Name>
            <Value>Unauthorized</Value>
        </AssignVariable>
        <Set>
            <Headers/>
            <Payload contentType="application/json">
                {
                    "code": "clienterror",
                    "userMessage": "Invalid B2B Client ID."
                }
            </Payload>
            <StatusCode>401</StatusCode>
            <ReasonPhrase>Unauthorized</ReasonPhrase>
        </Set>
    </FaultResponse>
    <IgnoreUnresolvedVariables>true</IgnoreUnresolvedVariables>
</RaiseFault>

I cannot see the variables set in above policy in the main proxy.

Can someone clarify if the fault policy is the last policy in the shared flow then the variables set in that policy does not get passed to the main proxy?

Or we cannot use AssignVariable tag in raise fault policy to populate any variables?

Thanks,

Santosh

0 1 354
1 REPLY 1

Santosh,

The enhancement to RaiseFault that allows the use of AssignVariable....

has not yet been rolled out to all pods in the public cloud yet.

Sorry I don't have a good estimate for when that will happen. I'm working on it as we speak. Soon?

ps: When that change is available to you, you will be able to adhere to DRY by doing this:

    <FaultResponse>
        <AssignVariable>
            <Name>api.error.code</Name>
            <Value>1234</Value>
        </AssignVariable>
        <AssignVariable>
            <Name>api.error.message</Name>
            <Value>Invalid B2B Client ID</Value>
        </AssignVariable>
        <AssignVariable>
            <Name>api.error.info</Name>
            <Template>https://developers.myapi.com/errors/{api.error.code}</Template>
        </AssignVariable>
        <AssignVariable>
            <Name>api.error.status</Name>
            <Value>401</Value>
        </AssignVariable>
        <AssignVariable>
            <Name>api.error.reason</Name>
            <Value>Unauthorized</Value>
        </AssignVariable>
        <Set>
            <Headers/>
            <Payload contentType="application/json">
                {
                    "code": "clienterror",
                    "userMessage": "{api.error.message}"
                }
            </Payload>
            <StatusCode>{api.error.status}</StatusCode>
            <ReasonPhrase>{api.error.reason}</ReasonPhrase>
        </Set>
    </FaultResponse>