{"fault":{"faultstring":"Evaluation of script pythonscript_name (py) failed with reason: error_type: error_description"","detail":{"errorcode":"steps.script.ScriptEvaluationFailed"}}}
가능한 원인
Python 스크립트 정책은 여러 가지 유형의 ScriptEvaluationFailed 오류를 발생시킬 수 있습니다. 아래 섹션에서는 이러한 오류 중 일부를 설명합니다.
NameError
PythonScript 코드에 정의 없이 참조되거나 연산되는 변수가 있는 경우, 이름 오류가 발생합니다.
오류 응답 본문
{"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"}}}
진단
오류 응답의 faultstring 요소에서 PythonScript 정책과 정의되지 않은 변수 이름을 식별합니다. 예를 들어 다음 faultstring에서 PythonScript 이름은 myscript.py이고 정의되지 않은 변수 이름은 num3입니다.
"faultstring":"Evaluation of script myscript.py (py) failed with reason: "NameError:'num3'isnotdefined""
위의 1단계에서 식별된 PythonScript 소스 파일을 검토하고 위의 1단계에서 식별된 정의되지 않은 변수가 참조되고 있는지 확인합니다. 예를 들어 다음 PythonScript 코드에서는 정의되지 않은 변수 num3을 참조하여 이는 faultstring의 오류와 일치합니다.
num1=1.5num2=6.3sum=float(num1)+float(num3)print('The sum of {0} and {1} is {2}'.format(num1,num3sum))
특정 변수가 PythonScript 코드 내에 정의되어 있는지 확인합니다. 변수가 정의되지 않은 경우 이는 오류의 원인이 됩니다.
위의 예제 스크립트에서 num3 변수는 정의되지 않았습니다. 따라서 다음과 같은 오류가 발생합니다.
"faultstring":"Evaluation of script myscript.py (py) failed with reason: "NameError:'num3'isnotdefined""
해결 방법
PythonScript 코드에서 참조된 모든 변수가 올바르게 정의되었는지 확인합니다.
위에 표시된 PythonScript 예시의 문제를 해결하려면 변수 num3을 사용하기 전에 정의합니다. 예를 들면 다음과 같습니다.
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
이 오류는 나누기 또는 모듈로 연산의 두 번째 인수가 0일 때 발생합니다.
오류 응답 본문
{"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"}}}
진단
PythonScript 정책 이름과 오류 응답의 faultstring 요소에서 실패한 이유를 식별합니다. 예를 들어 다음 faultstring에서 PythonScript 이름은 myscript.py이고 실패 이유는 integer division or modulo by zero입니다.
"faultstring":"Evaluation of script myscript.py (py) failed with reason: "ZeroDivisionError:integerdivisionormodulobyzero""
위의 1단계에서 식별된 PythonScript 소스 파일을 검사하여 0으로 나누기 또는 모듈로 연산을 하는지 확인합니다. 예를 들어 다음 PythonScript 코드에서는 0으로 나누기를 수행하며 이는 faultstring의 오류와 일치합니다.
a=0b=5c=b/aprintc
위의 예시 스크립트에서 나누기 연산의 두 번째 인수가 0이므로 다음과 같은 오류가 발생합니다.
"faultstring":"Evaluation of script myscript.py (py) failed with reason: "ZeroDivisionError:integerdivisionormodulobyzero""
해결 방법
PythonScript에서 나누기 또는 모듈로 연산의 두 번째 인수가 0이 아닌지 확인합니다.
위에 표시된 PythonScript 예시의 문제를 해결하려면 나누기 또는 모듈로 연산의 두 번째 인수로 0이 아닌 값을 사용합니다. 예를 들면 다음과 같습니다.
a=3b=5c=b/aprintc
추가 정보
위에 설명된 오류 외에도 steps.script.ScriptEvaluationFailed 오류가 발생할 수 있는 다른 원인이 많이 있습니다. 자세한 내용은 공식 Python 문서를 참조하세요.
[[["이해하기 쉬움","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."]]