search cancel

Export Variables outside Encapulated assertion with Raise Error Assertion

book

Article ID: 254154

calendar_today

Updated On:

Products

CA API Gateway

Issue/Introduction

Working on an encapulated assertion where the variables get exported when Stop Processing is used, but does not get exported when Raise Error is used.

Have tried to use Export Variables from Fragment assertion, but it is not working as expected.

How to export variables from a fragment when Raise Error assertion is used? 

Environment

Release : 10.x

Cause

The Raise Error Assertion stops policy execution and provides an error that policy execution is stopped. If a Raise Error Assertion is inside another assertion for example: a Handle Error Assertion, execution stops at the Raise Error point, but execution of the policy continues outside of the Handle Error Assertion block.

Resolution

In the fragment when Export Variable from Fragment assertion is used. The context variable value is set in the request.shared.<variable name> and context variable .   The context variable is local to the fragment and after Raise Error, it is gone, even it is specified in the export variables.  But request is "global" to the message handling policy so the values are kept after the execution/stop of the fragment. 

Key point:  when a Raise Error assertion is used in a fragment, the intended to export variable value is stored in the ${request.shared.<variable name>} in stead of the context variable <variable name>.   So if you want to export context variable ${v1},  the ${request.shared.v1} will have the value of ${v1},  but ${v1} itself will have no value if a Raise Error assertion is used in the fragment.

Example of export a variable ${v2} from encapsulated fragment: 

Assuem that in the above example Export Variable from Fragment assertion, v2 is checked, that means the fragment is trying to export the context variable ${v2} value. 

The policy that called the encapulated assertion can get the exported value of ${v2} from fragement by using context variable ${request.shared.v2}.  

The ${v2} itself will not have value after Raise Error assertion due to the fragment excution stopped and all the variable values set inside fragment are wiped out.  

 

Additional Information

About Raise Error assertion:

https://techdocs.broadcom.com/us/en/ca-enterprise-software/layer7-api-management/api-gateway/10-1/policy-assertions/assertion-palette/policy-logic-assertions/raise-error-assertion.html

Attachments