HTTPModifier policy deployment error troubleshooting

You're viewing Apigee X documentation.
View Apigee Edge documentation.

InvalidIndex

Error message

Deployment of the API proxy through either the Apigee UI or API fails with this error message:

Error in deployment for environment [environment]
The revision is deployed, but traffic cannot flow.
AssignMessage[policy_name]: index must be greater than zero in [attribute].[index]

Example error message

Error in deployment for environment test.
The revision is deployed, but traffic cannot flow.
HTTPModifier[GenerateStudentsRequest]: index must be greater than zero in id.0

Cause

If the index specified in the <Copy> and/or <Remove> elements of the HTTPModifier policy is 0 or a negative number, then deployment of the API Proxy fails.

For example, if you pass multiple query parameters with the same name, you can access them as indexed flow variables. Let's say you want to pass the IDs of 3 students as query parameters, then you can do it as follows:

https://$EXTERNAL_IP/$PROXY_BASEPATH?school_name=NPS&id=1&id=2&id=3

Then, let's say you attempt to access these query parameters with index numbers 0, 1, and 2 in the HTTPModifier policy as follows:

id.0
id.1 and
id.2

In this case, the deployment of the proxy fails because the index must start with 1. This means, you can access the first query parameter "id=1" as "id.1". To access the second query parameter "id=2", you need to use the index 2 i.e, "id.2". Similarly, to access the third query parameter "id=3", you can use "id.3".

For more information, see the AssignMessage policy Copy element documentation.

Diagnosis

  1. Identify the HTTPModifier policy where the error occurred, the name of the attribute, and the invalid index. You can find all these items in the error message. For example, in the following error, the policy name is GeneratingGeocodingRequest, the name of the attribute is id, and the index is 0:

    HTTPModifier[GenerateStudentsRequest]: index must be greater than zero in id.0
    
  2. Verify that the attribute name and the index used in the failed HTTPModifier policy XML matches the attribute name and the index identified in the error message (step #1 above). For example, the following policy specifies the attribute id and index as 0, which matches what's in the error message:

    <AssignMessage name="GenerateStudentsRequest">
      <AssignTo createNew="true" type="request">StudentsInfoRequest</AssignTo>
      <Copy source="request">
          <QueryParams>
              <QueryParam name="school_name"/>
              <QueryParam name="id.0"/>
              <QueryParam name="id.1"/>
              <QueryParam name="id.2"/>
          </QueryParams>
      </Copy>
    </AssignMessage>
    
  3. If the index specified is 0 or negative number, then that's the cause of the error.

    In the example Assign Message policy shown above, you are trying to access the first value of the query parameter "id" using the index 0. Hence the deployment of the API Proxy fails with the error:

    AssignMessage[GenerateStudentsRequest]: index must be greater than zero in id.0
    

Resolution

In HTTPModifier, when you access multiple headers, query parameters, or other parameters that share the same name, ensure that the index is always greater than zero. For example:

<AssignMessage name="GenerateStudentsRequest">
    <AssignTo createNew="true" type="request">StudentsInfoRequest</AssignTo>
    <Copy source="request">
        <QueryParams>
            <QueryParam name="school_name"/>
            <QueryParam name="id.1"/>
            <QueryParam name="id.2"/>
            <QueryParam name="id.3"/>
        </QueryParams>
    </Copy>
</AssignMessage>