You're viewing Apigee and Apigee hybrid documentation.
View
Apigee Edge documentation.
UnresolvedVariable
Error code
steps.assignmessage.UnresolvedVariable
Error response body
{ "fault": { "faultstring": "AssignMessage[policy_name]: unable to resolve variable [variable_name]", "detail": { "errorcode": "steps.assignmessage.UnresolvedVariable" } } }
Cause
This error occurs if a variable specified in the Assign Message policy is either:
- out of scope (not available in the specific flow where the policy is being executed) or
- can't be resolved (is not defined)
For example, this error occurs if the Assign Message policy executes in the request flow, but the source
attribute in the <Copy>
element is set to the response
or error
variable or any other custom variable that does not exist in the request flow.
Diagnosis
Identify the Assign Message Policy where the error occurred and the name of the variable that is not available. You can find both of these items in the
faultstring
element of the error response.For example, in the following
faultstring
, the policy name isgoogleBook
and the variable isvar
:"faultstring": "AssignMessage[googleBook]: unable to resolve variable var"
In the failed Assign Message Policy XML, verify that the name of the variable used matches the variable name identified in the fault string (step #1 above). For example, the following policy sets the source attribute in the
<Copy>
element to a variable namedvar
, which matches what's in thefaultstring
:<AssignMessage async="false" continueOnError="false" enabled="true" name="Assign-Message-1"> <DisplayName>googleBook</DisplayName> <Properties /> <Copy source="var"> <Headers> <Header name="user-agent" /> </Headers> </Copy> <IgnoreUnresolvedVariables>false</IgnoreUnresolvedVariables> <AssignTo createNew="true" transport="http" type="request">googleBookReq</AssignTo> </AssignMessage>
Determine if the variable is defined and available in the flow in which the Assign Message policy is being executed.
If the variable is either:
- out of scope (not available in the specific flow where the policy is being executed) or
- can't be resolved (is not defined)
then that's the cause for the error.
As an example, let's say the Assign Message policy shown above executes in the request flow. Check if the variable
var
is defined in any of the policies that are executed before the Assign Message policy in the request flow. If the variable has not been defined, then you will receive the error code:steps.assignmessage.UnresolvedVariable
Resolution
Ensure that the variable referenced in the policy exists and is available in the specific flow, where the Assign Message policy is being executed.
To correct the example policy shown above, you can modify the source attribute in the <Copy>
element to be the request variable or any other custom variable of type message that exists in the request flow.
<AssignMessage async="false" continueOnError="false" enabled="true" name="Assign-Message-1">
<DisplayName>googleBook</DisplayName>
<Properties />
<Copy source="request">
<Headers>
<Header name="user-agent" />
</Headers>
</Copy>
<IgnoreUnresolvedVariables>false</IgnoreUnresolvedVariables>
<AssignTo createNew="true" transport="http" type="request">googleBookReq</AssignTo>
</AssignMessage>
VariableOfNonMsgType
Error code
steps.assignmessage.VariableOfNonMsgType
Error response body
{ "fault": { "faultstring": "AssignMessage[policy_name]: value of variable [variable] is not of type Message", "detail": { "errorcode": "steps.assignmessage.VariableOfNonMsgType" } } }
Cause
This error occurs if the source
attribute in the <Copy>
element is set to a variable which is not of type message.
Message type variables represent entire HTTP requests and responses. The built-in flow variables request
, response
, and message
are of type message. To learn more about message variables, see the Variables reference.
Diagnosis
Identify the Assign Message Policy where the error occurred and the name of the variable whose type is incorrect. You can find both of these items in the
faultstring
element of the error response. For example, in the followingfaultstring
, the policy name isGenerateGeocodingRequest
and the variable isPostalCode
:"faultstring": "AssignMessage[GenerateGeocodingRequest]: value of variable PostalCode is not of type Message"
In the failed Assign Message Policy XML, verify that the name of the variable set in the
<Copy>
element matches the variable name identified in the fault string (step #1 above). For example, the following policy sets a source attribute to a variable namedPostalCode
, which matches what's in thefaultstring
:<AssignMessage name="GenerateGeocodingRequest"> <AssignTo createNew="true" type="request">GeocodingRequest</AssignTo> <AssignVariable> <Name>PostalCode</Name> <Ref>request.queryparam.postalcode</Ref> </AssignVariable> <AssignVariable> <Name>Country</Name> <Ref>request.queryparam.country</Ref> </AssignVariable> <Copy source="PostalCode"> <QueryParams> <QueryParam name="q" /> </QueryParams> </Copy> </AssignMessage>
Determine if this variable is of type message or not:
- Locate the code within the API Proxy bundle, where the variable was defined first.
- Once you figure out the policy in which the variable is defined and populated first, you need to determine the type of that variable as follows:
- Check the value of the type attribute (if present).
- If the type attribute is not present, then the variable is considered to be a string.
- If the variable's type is non-message (such as a string), then that's the cause of the error. You can learn about common variables and their types in the Variables reference.
For example, look at the PostalCode variable in the above XML. It is assigned the value of the flow variable
request.queryparam.postalcode
in the<AssignVariable>
element. This value is a string, because there is no type attribute present in the variable assignment.Now, recall that the PostalCode variable is used in the
<Copy>
element of the Assign Message policy:<Copy source="PostalCode"> <QueryParams> <QueryParam name="PostalCode" /> </QueryParams> </Copy>
Because PostalCode is not of type message (it's a string in this example), you receive the error code:
steps.assignmessage.VariableOfNonMsgType
Resolution
Ensure that the source
attribute in the <Copy>
element in the failed Assign Message policy is set to a message type flow variable that exists.
To correct the policy, you can modify the source
attribute in the <Copy>
element to specify a variable that is of type message. For example, if the Assign Message policy is supposed to execute in the request flow, then you could use the message type variable request
or any other custom variable of type message.
<AssignMessage name="GenerateGeocodingRequest">
<AssignTo createNew="true" type="request">GeocodingRequest</AssignTo>
<AssignVariable>
<Name>PostalCode</Name>
<Ref>request.queryparam.postalcode</Ref>
</AssignVariable>
<AssignVariable>
<Name>Country</Name>
<Ref>request.queryparam.country</Ref>
</AssignVariable>
<Copy source="request">
<QueryParams>
<QueryParam name="PostalCode" />
</QueryParams>
</Copy>
</AssignMessage>