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]
Error Saving Revision [revision_number]
The revision is deployed, but traffic cannot flow. AssignMessage schema validation failed: invalid variable name - null - in assign variable.
[[["容易理解","easyToUnderstand","thumb-up"],["確實解決了我的問題","solvedMyProblem","thumb-up"],["其他","otherUp","thumb-up"]],[["難以理解","hardToUnderstand","thumb-down"],["資訊或程式碼範例有誤","incorrectInformationOrSampleCode","thumb-down"],["缺少我需要的資訊/範例","missingTheInformationSamplesINeed","thumb-down"],["翻譯問題","translationIssue","thumb-down"],["其他","otherDown","thumb-down"]],["上次更新時間:2025-09-05 (世界標準時間)。"],[[["\u003cp\u003eThis documentation addresses common deployment errors in Apigee and Apigee hybrid related to the Assign Message policy, specifically focusing on \u003ccode\u003eInvalidIndex\u003c/code\u003e and \u003ccode\u003eInvalidVariableName\u003c/code\u003e errors.\u003c/p\u003e\n"],["\u003cp\u003eThe \u003ccode\u003eInvalidIndex\u003c/code\u003e error occurs when the index specified in the \u003ccode\u003e<Copy>\u003c/code\u003e or \u003ccode\u003e<Remove>\u003c/code\u003e elements of the Assign Message policy is zero or a negative number, which is not allowed when accessing indexed variables.\u003c/p\u003e\n"],["\u003cp\u003eTo resolve the \u003ccode\u003eInvalidIndex\u003c/code\u003e error, ensure that when using indexed variables, the index starts from 1 and increments accordingly for each subsequent parameter of the same name.\u003c/p\u003e\n"],["\u003cp\u003eThe \u003ccode\u003eInvalidVariableName\u003c/code\u003e error happens when the \u003ccode\u003e<Name>\u003c/code\u003e element within the \u003ccode\u003e<AssignVariable>\u003c/code\u003e element of an Assign Message policy is empty or not defined, and it requires a valid variable name.\u003c/p\u003e\n"],["\u003cp\u003eFixing the \u003ccode\u003eInvalidVariableName\u003c/code\u003e error involves ensuring that the \u003ccode\u003e<Name>\u003c/code\u003e element is always specified with a non-empty value inside the \u003ccode\u003e<AssignVariable>\u003c/code\u003e tag.\u003c/p\u003e\n"]]],[],null,["# Assign Message policy deployment error troubleshooting\n\n*You're viewing **Apigee** and **Apigee hybrid** documentation.\nView [Apigee Edge](https://docs.apigee.com/api-platform/troubleshoot/policies/deployment/assign-message-deployment-errors) documentation.*\n| Was this troubleshooting playbook helpful? Please let us know by clicking [Send Feedback]().\n\nInvalidIndex\n------------\n\n### Error message\n\nDeployment of the API proxy through either the Apigee UI or API fails with this error message: \n\n```\nError in deployment for environment [environment]\nThe revision is deployed, but traffic cannot flow.\nAssignMessage[policy_name]: index must be greater than zero in [attribute].[index]\n```\n\n**Example error message** \n\n Error in deployment for environment test.\n The revision is deployed, but traffic cannot flow.\n AssignMessage[GenerateStudentsRequest]: index must be greater than zero in id.0\n\n**Example screenshot**\n\n### Cause\n\nIf the index specified in the `\u003cCopy\u003e` and/or `\u003cRemove\u003e` elements of the Assign Message policy is 0 or a negative number, then deployment of the API Proxy fails.\n\nFor 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: \n\n https://$EXTERNAL_IP/$PROXY_BASEPATH?school_name=NPS&id=1&id=2&id=3\n\nThen, let's say you attempt to access these query parameters with index numbers 0, 1, and 2 in the Assign Message policy as follows: \n\n id.0\n id.1 and\n id.2\n\nIn 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\".\n\nFor more information, see the [AssignMessage policy Copy element documentation](/apigee/docs/api-platform/reference/policies/assign-message-policy#copy).\n\n### Diagnosis\n\n1. Identify the Assign Message 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`:\n\n AssignMessage[GenerateStudentsRequest]: index must be greater than zero in id.0\n\n2. Verify that the attribute name and the index used in the failed Assign Message 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:\n\n ```carbon\n \u003cAssignMessage name=\"GenerateStudentsRequest\"\u003e\n \u003cAssignTo createNew=\"true\" type=\"request\"\u003eStudentsInfoRequest\u003c/AssignTo\u003e\n \u003cCopy source=\"request\"\u003e\n \u003cQueryParams\u003e\n \u003cQueryParam name=\"school_name\"/\u003e\n \u003cQueryParam name=\"id.0\"/\u003e\n \u003cQueryParam name=\"id.1\"/\u003e\n \u003cQueryParam name=\"id.2\"/\u003e\n \u003c/QueryParams\u003e\n \u003c/Copy\u003e\n \u003c/AssignMessage\u003e\n ```\n3. If the index specified is 0 or negative number, then that's the cause of the error.\n\n 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: \n\n AssignMessage[GenerateStudentsRequest]: index must be greater than zero in id.0\n\n### Resolution\n\nIn Assign Message, 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: \n\n \u003cAssignMessage name=\"GenerateStudentsRequest\"\u003e\n \u003cAssignTo createNew=\"true\" type=\"request\"\u003eStudentsInfoRequest\u003c/AssignTo\u003e\n \u003cCopy source=\"request\"\u003e\n \u003cQueryParams\u003e\n \u003cQueryParam name=\"school_name\"/\u003e\n \u003cQueryParam name=\"id.1\"/\u003e\n \u003cQueryParam name=\"id.2\"/\u003e\n \u003cQueryParam name=\"id.3\"/\u003e\n \u003c/QueryParams\u003e\n \u003c/Copy\u003e\n \u003c/AssignMessage\u003e\n\nInvalidVariableName\n-------------------\n\n### Error message\n\nDeployment of the API proxy through either the Apigee UI or API fails with this error message: \n\n```\nError Saving Revision [revision_number]\nThe revision is deployed, but traffic cannot flow. AssignMessage schema validation failed: invalid variable name - null - in assign variable.\n```\n\n**Example error message** \n\n Error Saving Revision 3\n AssignMessage schema validation failed: invalid variable name - null - in assign variable.\n\n**Example screenshot**\n\n### Cause\n\nIf the child element `\u003cName\u003e` is empty or not specified in the `\u003cAssignVariable\u003e` element, then the deployment of the API proxy fails because there is no valid variable name to which to assign a value. A valid variable name is required.\n\n### Diagnosis\n\nExamine all the Assign Message policies in the specific API Proxy where the failure has occurred. If there is any Assign Message policy in which the child element `\u003cName\u003e` is empty or not specified in the `\u003cAssignVariable\u003e` element, then that's the cause of the error.\n\n**Example 1: The following Assign Message policy has no `\u003cName\u003e` element defined.** \n\n \u003cAssignMessage async=\"false\" continueOnError=\"false\" enabled=\"true\" name=\"Assign-Message-1\"\u003e\n \u003cDisplayName\u003eAssign Message-1\u003c/DisplayName\u003e\n \u003cProperties/\u003e\n \u003cAssignVariable\u003e\n \u003cValue\u003eabcd1234\u003c/Value\u003e\n \u003c/AssignVariable\u003e\n \u003cIgnoreUnresolvedVariables\u003efalse\u003c/IgnoreUnresolvedVariables\u003e\n \u003cAssignTo createNew=\"true\" transport=\"http\" type=\"request\"\u003egoogleBookReq\u003c/AssignTo\u003e\n \u003c/AssignMessage\u003e\n\n**Example 2: The following Assign Message policy has an empty `\u003cName\u003e` element .** \n\n \u003cAssignMessage async=\"false\" continueOnError=\"false\" enabled=\"true\" name=\"Assign-Message-1\"\u003e\n \u003cDisplayName\u003eAssign Message-1\u003c/DisplayName\u003e\n \u003cProperties/\u003e\n \u003cAssignVariable\u003e\n \u003cName\u003e\u003c/Name\u003e\n \u003cValue\u003eabcd1234\u003c/Value\u003e\n \u003c/AssignVariable\u003e\n \u003cIgnoreUnresolvedVariables\u003efalse\u003c/IgnoreUnresolvedVariables\u003e\n \u003cAssignTo createNew=\"true\" transport=\"http\" type=\"request\"\u003egoogleBookReq\u003c/AssignTo\u003e\n \u003c/AssignMessage\u003e\n\n### Resolution\n\nEnsure that the child element `\u003cName\u003e` is always specified and non-empty within the `\u003cAssignVariable\u003e` element of the Assign Message policy. For example: \n\n```carbon\n\u003cAssignMessage async=\"false\" continueOnError=\"false\" enabled=\"true\" name=\"Assign-Message-1\"\u003e\n \u003cDisplayName\u003eAssign Message-1\u003c/DisplayName\u003e\n \u003cProperties/\u003e\n \u003cAssignVariable\u003e\n \u003cName\u003eappSecret\u003c/Name\u003e\n \u003cValue\u003eabcd1234\u003c/Value\u003e\n \u003c/AssignVariable\u003e\n \u003cIgnoreUnresolvedVariables\u003efalse\u003c/IgnoreUnresolvedVariables\u003e\n \u003cAssignTo createNew=\"true\" transport=\"http\" type=\"request\"\u003egoogleBookReq\u003c/AssignTo\u003e\n\u003c/AssignMessage\u003e\n```"]]