{"fault":{"faultstring":"Evaluation of script pythonscript_name (py) failed with reason: error_type: error_description"","detail":{"errorcode":"steps.script.ScriptEvaluationFailed"}}}
{"fault":{"faultstring":"Evaluation of script pythonscript_name (py) failed with reason: "NameError:variable_nameisnotdefined"","detail":{"errorcode":"steps.script.ScriptEvaluationFailed"}}}
エラー レスポンスの本文の例
{"fault":{"faultstring":"Evaluation of script myscript.py (py) failed with reason: "NameError:'num3'isnotdefined"","detail":{"errorcode":"steps.script.ScriptEvaluationFailed"}}}
num1=1.5num2=6.3num3=8.7sum=float(num1)+float(num3)print('The sum of {0} and {1} is {2}'.format(num1,num3,sum))
ZeroDivisionError:
このエラーは、除算または剰余演算の 2 番目の引数がゼロである場合に発生します。
エラー レスポンスの本文
{"fault":{"faultstring":"Evaluation of script pythonscript_name (py) failed with reason: "ZeroDivisionError:reason_for_error"","detail":{"errorcode":"steps.script.ScriptEvaluationFailed"}}}
エラー レスポンスの本文の例
{"fault":{"faultstring":"Evaluation of script myscript.py (py) failed with reason: "ZeroDivisionError:integerdivisionormodulobyzero"","detail":{"errorcode":"steps.script.ScriptEvaluationFailed"}}}
診断
エラー レスポンスの faultstring 要素から、PythonScript ポリシー名とエラーの原因を特定します。たとえば、次の faultstring では、PythonScript 名が myscript.py で、エラーの原因は integer division or modulo by zero です。
"faultstring":"Evaluation of script myscript.py (py) failed with reason: "ZeroDivisionError:integerdivisionormodulobyzero""
[[["わかりやすい","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-04 UTC。"],[[["\u003cp\u003eThis documentation focuses on troubleshooting \u003ccode\u003eScriptEvaluationFailed\u003c/code\u003e errors in Apigee and Apigee hybrid PythonScript policies.\u003c/p\u003e\n"],["\u003cp\u003eA common cause of the \u003ccode\u003eScriptEvaluationFailed\u003c/code\u003e error is \u003ccode\u003eNameError\u003c/code\u003e, which occurs when a variable is referenced in the PythonScript without being defined, this section explains how to diagnose and resolve the error.\u003c/p\u003e\n"],["\u003cp\u003eAnother common cause of this error is \u003ccode\u003eZeroDivisionError\u003c/code\u003e, which happens when a division or modulo operation attempts to divide by zero, and explains how to identify and resolve this.\u003c/p\u003e\n"],["\u003cp\u003eThe document provides concrete examples of error response bodies and shows how to diagnose each, in addition to showing how the errors can be resolved.\u003c/p\u003e\n"]]],[],null,["# PythonScript policy runtime error troubleshooting\n\n*You're viewing **Apigee** and **Apigee hybrid** documentation.\nView [Apigee Edge](https://docs.apigee.com/api-platform/troubleshoot/policies/runtime/python-script-runtime-errors) documentation.*\n| **Note:** Was this troubleshooting playbook helpful? Please let us know by clicking [Send Feedback]().\n\nScriptEvaluationFailed\n----------------------\n\n### Error code\n\n steps.script.ScriptEvaluationFailed\n\n### Error response body\n\n```python\n{\n \"fault\": {\n \"faultstring\": \"Evaluation of script \u003cvar translate=\"no\"\u003epythonscript_name\u003c/var\u003e (py) failed with reason: \u003cvar translate=\"no\"\u003eerror_type\u003c/var\u003e: \u003cvar translate=\"no\"\u003eerror_description\u003c/var\u003e\"\",\n \"detail\": {\n \"errorcode\": \"steps.script.ScriptEvaluationFailed\"\n }\n }\n}\n```\n\n### Possible causes\n\nThe [Python Script](/apigee/docs/api-platform/reference/policies/python-script-policy) policy can\nthrow several different types of `ScriptEvaluationFailed` errors. The sections below describe some of these errors.\n\nNameError\n---------\n\nIf there is a variable in the PythonScript code which is referenced or operated on without being defined, then you get the Name error.\n\n### Error response body\n\n```python\n{\n \"fault\": {\n \"faultstring\": \"Evaluation of script \u003cvar translate=\"no\"\u003epythonscript_name\u003c/var\u003e (py) failed with reason: \"NameError: variable_name is not defined\"\",\n \"detail\": {\n \"errorcode\": \"steps.script.ScriptEvaluationFailed\"\n }\n }\n}\n```\n\n### Example error response body\n\n```python\n{\n \"fault\": {\n \"faultstring\": \"Evaluation of script myscript.py (py) failed with reason: \"NameError: 'num3' is not defined\"\",\n \"detail\": {\n \"errorcode\": \"steps.script.ScriptEvaluationFailed\"\n }\n }\n}\n```\n\n### Diagnosis\n\n1. Identify the PythonScript policy and the undefined variable name from the faultstring element of the error response. For example, in the following faultstring, the PythonScript name is `myscript.py` and the undefined variable name is **num3**:\n\n ```python\n \"faultstring\": \"Evaluation of script myscript.py (py) failed with reason: \"NameError: 'num3' is not defined\"\"\n ```\n2. Examine the PythonScript source file identified in step #1 above and verify if the undefined variable identified in step #1 above is being referenced. For example, the following PythonScript code references the undefined variable **num3**, which matches the faultstring:\n\n ```python\n num1 = 1.5\n num2 = 6.3\n sum = float(num1) + float(num3)\n print('The sum of {0} and {1} is {2}'.format(num1, num3 sum))\n ```\n3. Check if the specific variable is defined within the PythonScript code. If the variable is not defined, then that's the cause for the error.\n\n In the example script shown above, the variable **num3** is undefined. Therefore, you will get the below error:\n\n \u003cbr /\u003e\n\n ```python\n \"faultstring\": \"Evaluation of script myscript.py (py) failed with reason: \"NameError: 'num3' is not defined\"\"\n ```\n\n \u003cbr /\u003e\n\n### Resolution\n\nEnsure that all the variables referenced in the PythonScript code are properly defined.\n\nTo fix the issue with the example PythonScript shown above, define the variable **num3** before using it. For example: \n\n```python\nnum1 = 1.5\nnum2 = 6.3\nnum3 = 8.7\nsum = float(num1) + float(num3)\nprint('The sum of {0} and {1} is {2}'.format(num1, num3, sum))\n```\n\nZeroDivisionError\n-----------------\n\nThis error is raised when the second argument of a division or modulo operation is zero.\n\n### Error response body\n\n```python\n{\n \"fault\": {\n \"faultstring\": \"Evaluation of script \u003cvar translate=\"no\"\u003epythonscript_name\u003c/var\u003e (py) failed with reason: \"ZeroDivisionError: reason_for_error\"\",\n \"detail\": {\n \"errorcode\": \"steps.script.ScriptEvaluationFailed\"\n }\n }\n}\n```\n\n### Example error response body\n\n```python\n{\n \"fault\": {\n \"faultstring\": \"Evaluation of script myscript.py (py) failed with reason: \"ZeroDivisionError: integer division or modulo by zero\"\",\n \"detail\": {\n \"errorcode\": \"steps.script.ScriptEvaluationFailed\"\n }\n }\n}\n```\n\n### Diagnosis\n\n1. Identify the PythonScript policy name and the reason for failure from the faultstring element of the error response. For example, in the following faultstring, the PythonScript name is `myscript.py` and the reason for failure is `integer division or modulo by zero`:\n\n ```python\n \"faultstring\": \"Evaluation of script myscript.py (py) failed with reason: \"ZeroDivisionError: integer division or modulo by zero\"\"\n ```\n2. Examine the PythonScript source file identified in step #1 above and verify if there's a division or a modulus operation by zero. For example, the following PythonScript code performs division by zero, which matches with what's in the faultstring:\n\n ```python\n a = 0\n b = 5\n c = b/a\n print c\n ```\n\n In the example script shown above, because the second argument of the division operation is zero, you get the following error: \n\n ```python\n \"faultstring\": \"Evaluation of script myscript.py (py) failed with reason: \"ZeroDivisionError: integer division or modulo by zero\"\"\n ```\n\n### Resolution\n\nEnsure that the second argument of a division or modulo operation is non zero in the PythonScript.\n\nTo fix the issue with the example PythonScript shown above, use a non zero value as the second argument of a division or modulo operation. For example: \n\n```python\na = 3\nb = 5\nc = b/a\nprint c\n```\n\nMore Information\n----------------\n\nThere are many other possible causes for the error `steps.script.ScriptEvaluationFailed` apart from the ones described above. Please refer to the official [Python documentation](https://docs.python.org/3/library/exceptions.html) for more information."]]