[[["容易理解","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-08-18 (世界標準時間)。"],[[["\u003cp\u003eThis documentation covers troubleshooting for two specific error codes within Apigee and Apigee hybrid environments: \u003ccode\u003epolicies.ratelimit.InvalidMessageWeight\u003c/code\u003e and \u003ccode\u003epolicies.ratelimit.FailedToResolveSpikeArrestRate\u003c/code\u003e.\u003c/p\u003e\n"],["\u003cp\u003eThe \u003ccode\u003epolicies.ratelimit.InvalidMessageWeight\u003c/code\u003e error occurs when a non-integer value is used for the \u003ccode\u003e<MessageWeight>\u003c/code\u003e element within a Spike Arrest policy, which can be diagnosed by examining the \u003ccode\u003efaultstring\u003c/code\u003e and the definition of the message weight variable.\u003c/p\u003e\n"],["\u003cp\u003eThe \u003ccode\u003epolicies.ratelimit.FailedToResolveSpikeArrestRate\u003c/code\u003e error happens when the \u003ccode\u003e<Rate>\u003c/code\u003e element in a Spike Arrest policy refers to a variable that is undefined or not available in the current flow, and its diagnosis involves identifying the unresolved reference and verifying its availability in the flow.\u003c/p\u003e\n"],["\u003cp\u003eResolving the \u003ccode\u003eInvalidMessageWeight\u003c/code\u003e error involves ensuring that the \u003ccode\u003e<MessageWeight>\u003c/code\u003e value is an integer, while fixing the \u003ccode\u003eFailedToResolveSpikeArrestRate\u003c/code\u003e error requires verifying that the referenced variable within \u003ccode\u003e<Rate>\u003c/code\u003e is defined and accessible in the policy's execution flow.\u003c/p\u003e\n"],["\u003cp\u003eThe rate for the spike arrest policy is to be of the format {int}pm or {int}ps, for instance, 500pm or 10ps.\u003c/p\u003e\n"]]],[],null,["*You're viewing **Apigee** and **Apigee hybrid** documentation.\nView [Apigee Edge](https://docs.apigee.com/api-platform/troubleshoot/policies/runtime/spike-arrest-runtime-errors) documentation.*\n| **Note:** Was this troubleshooting playbook helpful? Please let us know by clicking [Send Feedback]().\n\nInvalidMessageWeight\n\nError code \n\n policies.ratelimit.InvalidMessageWeight\n\nError response body \n\n```transact-sql\n{\n \"fault\": {jdoe\n \"faultstring\": \"Invalid message weight value [\u003cvar translate=\"no\"\u003einvalid_value\u003c/var\u003e]\",\n \"detail\": {\n \"errorcode\": \"policies.ratelimit.InvalidMessageWeight\"\n }\n }\n}\n```\n\n**Example Error Message** \n\n```text\n{\n \"fault\": {\n \"faultstring\": \"Invalid message weight value 1.5\",\n \"detail\": {\n \"errorcode\": \"policies.ratelimit.InvalidMessageWeight\"\n }\n }\n}\n```\n\nCause\n\nThis error occurs if the value specified for the `\u003cMessageWeight\u003e` element through\na flow variable is invalid (a non-integer value).\n\nFor example, if the value of the flow variable specified for the `\u003cMessageWeight\u003e`\nelement is 1.5 (a non-integer value), then the error occurs.\n\nDiagnosis\n\n1. Identify the invalid value used for the `\u003cMessageWeight\u003e` element in the Spike\n Arrest policy. You can find this information in the `faultstring` element of the\n error response. For example, in the following error, the invalid value used for\n `\u003cMessageWeight\u003e` element is `1.5`:\n\n \"faultstring\": \"Invalid message weight value 1.5\"\n\n2. Examine all the Spike Arrest policies in the specific API Proxy where the\n failure has occurred. There could be one or more Spike Arrest policies in which\n the `\u003cMessageWeight\u003e` element is specified.\n\n For example, the following policy specifies the value of `\u003cMessageWeight\u003e`\n through a flow variable called `message_weight:` \n\n \u003c?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?\u003e\n \u003cSpikeArrest async=\"false\" continueOnError=\"false\" enabled=\"true\" name=\"SpikeArrest_AuthProxy\"\u003e\n \u003cDisplayName\u003eSpikeArrest_AuthProxy\u003c/DisplayName\u003e\n \u003cProperties/\u003e\n \u003cIdentifier ref=\"request.header.some-header-name\"/\u003e\n \u003cRate\u003e100ps\u003c/Rate\u003e\n \u003cMessageWeight ref=\"message_weight\"/\u003e\n \u003c/SpikeArrest\u003e\n\n3. Determine the value of the variable used in the `\u003cMessageWeight\u003e` element of\n the identified Spike Arrest Policy(ies). The value of the flow variable can be\n extracted from HTTP headers, query parameters, an XML or JSON request payload,\n or defined in another policy.\n\n 1. Locate the code within the API proxy, where the variable was defined first.\n 2. Once you figure out the policy in which the variable is defined and populated first, check how the value for the variable is set.\n 3. If the value of the flow variable matches the value identified in Step #1 above, then that's the cause of the error.\n\n For example, assume that a JavaScript policy is used before the Spike Arrest\n Policy to set the variable `message_weight` based on the request method as\n shown below: \n\n var verb = context.getVariable(\"request.verb\");\n context.setVariable(\"message_weight\", \"1.5\");\n if (verb == 'POST') {\n context.setVariable(\"message_weight\", \"2\");\n }\n\n Notice that the value of the variable `message_weight` is `1.5` which is\n invalid (a non-integer) value.\n\nResolution\n\nEnsure that the value of the `MessageWeight` element is a valid value (integer\nvalue).\n\nTo correct the example shown above, you can modify the value of the variable\n`message_weight` in the JavaScript to be an integer: \n\n var verb = context.getVariable(\"request.verb\");\n context.setVariable(\"message_weight\", \"1\");\n if (verb == 'POST') {\n context.setVariable(\"message_weight\", \"2\");\n }\n\nFailedToResolveSpikeArrestRate\n\nError code \n\n policies.ratelimit.FailedToResolveSpikeArrestRate\n\nError response body \n\n```transact-sql\n{\n \"fault\": {\n \"faultstring\": \"Failed to resolve Spike Arrest Rate reference [\u003cvar translate=\"no\"\u003ereference\u003c/var\u003e] in SpikeArrest policy [\u003cvar translate=\"no\"\u003eapi_policy\u003c/var\u003e]\",\n \"detail\": {\n \"errorcode\": \"policies.ratelimit.FailedToResolveSpikeArrestRate\"\n }\n }\n}\n```\n\n**Example Error Message** \n\n```scdoc\n{\n \"fault\": {\n \"faultstring\": \"Failed to resolve Spike Arrest Rate reference request.header.rate in SpikeArrest policy SpikeArrest_AuthProxy\",\n \"detail\": {\n \"errorcode\": \"policies.ratelimit.FailedToResolveSpikeArrestRate\"\n }\n }\n}\n```\n\nCause\n\nThis error occurs if the reference to the variable containing the rate setting\nwithin the `\u003cRate\u003e` element cannot be resolved to a value within the Spike Arrest\npolicy. This element is mandatory and used to specify the spike arrest rate in\nthe form of `{int}pm` or `{int}ps`. For example, `{int}pm` might be `500pm`,\nwhich means 500 calls per minute. Likewise, a value of `10ps` means 10 calls per\nsecond.\n\nDiagnosis\n\n1. Identify the Spike Arrest policy where the error occurred and the name of\n the reference that cannot be resolved properly. You can find both of these items\n in the faultstring element of the error response.\n\n For example, in the following faultstring, the policy name is\n `SpikeArrest_AuthProxy` and the reference is `request.header.rate`: \n\n \"faultstring\": \"Failed to resolve Spike Arrest Rate reference request.header.rate in SpikeArrest policy SpikeArrest_AuthProxy\"\n\n2. In the failed Spike Arrest policy XML, verify that the name of the reference\n used matches the reference name identified in the fault string (step #1 above). \\*\\* \\*\\*\n\n For example, the following policy sets the element with the reference named `request.header.rate`, which matches what's in the faultstring: \n\n \u003c?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?\u003e\n \u003cSpikeArrest async=\"false\" continueOnError=\"false\" enabled=\"true\" name=\"SpikeArrest_AuthProxy\"\u003e\n \u003cDisplayName\u003eSpikeArrest_AuthProxy\u003c/DisplayName\u003e\n \u003cProperties/\u003e\n \u003cIdentifier ref=\"request.header.some-header-name\"/\u003e\n \u003cRate ref=\"request.header.rate\"/\u003e\n \u003c/SpikeArrest\u003e\n\n3. Determine if the variable is defined and available in the flow in which the\n Spike Arrest policy is being executed.\n\n4. If the variable is either:\n\n - out of scope (not available in the specific flow where the policy is being executed) or\n - can't be resolved (is not defined)\n\n then that's the cause for the error.\n\n In the example shown above, the value of the spike arrest rate in the `\u003cRate\u003e`\n element is supposed to be retrieved from the request header named **rate** .\n However, Apigee is unable to resolve the **request.header.rate** . This happens\n if the header **rate** is not passed as part of the API request.\n\n Here's a sample API request that does not pass the header **rate** as part of\n the request: \n\n ```\n curl -v http://your_host_alias/check_spikearrest -H \"Content-Type: application/json\"\n ```\n\n\n Where \u003cvar translate=\"no\"\u003eyour_host_alias\u003c/var\u003e is a publicly facing domain used to access your APIs,\n as configured in the `virtualhosts.hostAliases` property in your overrides file.\n See [Specify configuration\n overrides](/apigee/docs/hybrid/latest/2-6-install-configure-cluster#specify-configuration-overrides).\n\n \u003cbr /\u003e\n\n Since the header **rate** is not passed as part of the request, reference\n **request.header.rate** used in the element `\u003cRate\u003e` in the above Spike\n Arrest policy is undefined and hence cannot be resolved. So you will receive\n the error code: \n\n policies.ratelimit.FailedToResolveSpikeArrestRate\n\nResolution\n\nEnsure that the variable referenced in the `\u003cRate\u003e` element exists/is defined\nand available in the specific flow, where the Spike Arrest policy is being executed.\n\nTo correct the example shown above, you can modify the request to include the **rate** header as shown below: \n\n```\ncurl -v http://your_host_alias/check_spikearrest -H \"Content-Type: application/json\" -H \"rate:30ps\"\n```\n\n\nWhere \u003cvar translate=\"no\"\u003eyour_host_alias\u003c/var\u003e is a publicly facing domain used to access your APIs,\nas configured in the `virtualhosts.hostAliases` property in your overrides file.\nSee [Specify configuration\noverrides](/apigee/docs/hybrid/latest/2-6-install-configure-cluster#specify-configuration-overrides).\n\n\u003cbr /\u003e"]]