Risoluzione degli errori di deployment dei criteri HTTPModifier
Mantieni tutto organizzato con le raccolte
Salva e classifica i contenuti in base alle tue preferenze.
Stai visualizzando la documentazione di Apigee X.
Visualizza la documentazione di
Apigee Edge.
InvalidIndex
Messaggio di errore
Il deployment del proxy API tramite l'API o l'interfaccia utente di Apigee non va a buon fine con questo messaggio di errore:
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]
Se l'indice specificato negli elementi <Copy> e/o <Remove> del criterio HTTPModifier è 0 o un numero negativo, il deployment del proxy API non va a buon fine.
Ad esempio, se passi più parametri di ricerca con lo stesso nome, puoi accedervi come variabili di flusso indicizzate. Supponiamo che tu voglia passare gli ID di tre studenti come parametri di ricerca. A questo scopo, puoi procedere nel seguente modo:
Supponiamo quindi che tu tenti di accedere a questi parametri di ricerca con i numeri di indice 0, 1 e 2 nel criterio HTTPModifier come segue:
id.0
id.1 and
id.2
In questo caso, il deployment del proxy non va a buon fine perché l'indice deve iniziare con 1. Ciò significa che puoi accedere al primo parametro di query "id=1" come "id.1". Per accedere al secondo parametro di query "id=2", devi utilizzare l'indice 2, ovvero "id.2". Analogamente, per accedere al terzo parametro di query "id=3", puoi utilizzare "id.3".
Identifica il criterio HTTPModifier in cui si è verificato l'errore, il nome dell'attributo e l'indice non valido. Puoi trovare tutti questi elementi nel messaggio di errore. Ad esempio, nel seguente errore, il nome del criterio è GeneratingGeocodingRequest, il nome dell'attributo è id e l'indice è 0:
Verifica che il nome dell'attributo e l'indice utilizzati nel file XML della policy HTTPModifier non riuscita corrispondano al nome dell'attributo e all'indice identificati nel messaggio di errore (passaggio 1 sopra). Ad esempio, il seguente criterio specifica l'attributo id e l'indice come 0, che corrisponde a quanto indicato nel messaggio di errore:
Se l'indice specificato è 0 o un numero negativo, è la causa dell'errore.
Nell'esempio del criterio Assegna messaggio mostrato sopra, stai tentando di accedere al primo valore del parametro di query "id" utilizzando l'indice 0. Di conseguenza, il deployment del proxy API non va a buon fine con l'errore:
In HTTPModifier, quando accedi a più intestazioni, parametri di ricerca o altri parametri che condividono lo stesso nome, assicurati che l'indice sia sempre maggiore di zero. Ad esempio:
[[["Facile da capire","easyToUnderstand","thumb-up"],["Il problema è stato risolto","solvedMyProblem","thumb-up"],["Altra","otherUp","thumb-up"]],[["Difficile da capire","hardToUnderstand","thumb-down"],["Informazioni o codice di esempio errati","incorrectInformationOrSampleCode","thumb-down"],["Mancano le informazioni o gli esempi di cui ho bisogno","missingTheInformationSamplesINeed","thumb-down"],["Problema di traduzione","translationIssue","thumb-down"],["Altra","otherDown","thumb-down"]],["Ultimo aggiornamento 2025-09-04 UTC."],[[["\u003cp\u003eAPI proxy deployment in Apigee X can fail with an "index must be greater than zero" error when using the HTTPModifier policy.\u003c/p\u003e\n"],["\u003cp\u003eThis error occurs if the \u003ccode\u003e<Copy>\u003c/code\u003e or \u003ccode\u003e<Remove>\u003c/code\u003e elements within the HTTPModifier policy attempt to access indexed flow variables with an index of 0 or a negative number.\u003c/p\u003e\n"],["\u003cp\u003eThe index in the HTTPModifier policy, when dealing with parameters that share the same name, must start at 1, not 0.\u003c/p\u003e\n"],["\u003cp\u003eTo resolve this, verify the index in the failing HTTPModifier policy, ensure that it is a positive number greater than zero, and adjust the index accordingly in the policy definition.\u003c/p\u003e\n"]]],[],null,["# HTTPModifier policy deployment error troubleshooting\n\n*You're viewing **Apigee X** 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 HTTPModifier[GenerateStudentsRequest]: index must be greater than zero in id.0\n\n### Cause\n\nIf the index specified in the `\u003cCopy\u003e` and/or `\u003cRemove\u003e` elements of the HTTPModifier 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 HTTPModifier 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 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`:\n\n HTTPModifier[GenerateStudentsRequest]: index must be greater than zero in id.0\n\n2. 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:\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 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: \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"]]