[[["わかりやすい","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 UTC。"],[[["\u003cp\u003eThis documentation addresses common deployment errors in Apigee and Apigee hybrid related to PythonScript policies.\u003c/p\u003e\n"],["\u003cp\u003eThe \u003ccode\u003eInvalidResourceUrlFormat\u003c/code\u003e error occurs when the \u003ccode\u003e<ResourceURL>\u003c/code\u003e or \u003ccode\u003e<IncludeURL>\u003c/code\u003e format in a PythonScript policy is incorrect, such as using \u003ccode\u003epy:filename.py\u003c/code\u003e instead of \u003ccode\u003epy://filename.py\u003c/code\u003e.\u003c/p\u003e\n"],["\u003cp\u003eThe \u003ccode\u003eInvalidResourceUrlReference\u003c/code\u003e error occurs when a PythonScript policy's \u003ccode\u003e<ResourceURL>\u003c/code\u003e or \u003ccode\u003e<IncludeURL>\u003c/code\u003e points to a file that does not exist within the API proxy bundle or the environment level.\u003c/p\u003e\n"],["\u003cp\u003eTo resolve these issues, ensure that resource URLs follow the \u003ccode\u003epy://filename.py\u003c/code\u003e format and that referenced Python files are located within the API proxy's Scripts section or at the environment level.\u003c/p\u003e\n"]]],[],null,["# PythonScript 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/python-script-deployment-errors) documentation.*\n| Was this troubleshooting playbook helpful? Please let us know by clicking [Send Feedback]().\n\nInvalidResourceUrlFormat\n------------------------\n\n### Error message\n\nDeployment of an API proxy through either the Apigee UI or API fails with this error message: \n\n```python\nError Deploying Revision revision_number to environment\nInvalid resource url format. Resource url is invalid_URL.\n```\n\n### Example error message\n\n```python\nError Deploying Revision 2 to prod\nInvalid resource url format. Resource url is py:myscript.py.\n```\n\n### Example screenshot\n\n### Cause\n\nIf the format of the resource URL specified within the `\u003cResourceURL\u003e` or the `\u003cIncludeURL\u003e` element of the\n[PythonScript policy](/apigee/docs/api-platform/reference/policies/python-script-policy) is invalid, then the deployment of the API proxy fails.\n\nThe correct format is as shown below: \n\n```python\n\u003cResourceURL\u003epy://file_name.py\u003c/ResourceURL\u003e\n\u003cIncludeURL\u003epy://file_name.py\u003c/IncludeURL\u003e\n```\n\nFor example, if the `\u003cResourceURL\u003e` element is specified as shown below, then the\ndeployment of the API proxy fails because it does not follow the required pattern: \n\n```python\n\u003cResourceURL\u003epy:myscript.py\u003c/ResourceURL\u003e\n```\n\n### Diagnosis\n\n1. Identify the invalid resource URL format used in the PythonScript policy. You can find this information from the error message. For example, in the following error, the invalid resource URL format is `py:myscript.py`:\n\n ```python\n Invalid resource url format. Resource url is py:myscript.py.\n ```\n2. Examine all the PythonScript policies in the specific API Proxy where the failure has occurred. If there is any PythonScript policy in which the resource URL specified in the `\u003cResourceURL\u003e` or the `\u003cIncludeURL\u003e` element matches the invalid entry identified in step #1 above, then that's the cause of the error.\n\n For example, the following policy specifies the resource URL as `py:myscript.py`, which matches what's in the error message: \n\n ```python\n \u003c?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?\u003e\n \u003cScript async=\"false\" continueOnError=\"false\" enabled=\"true\" timeLimit=\"200\" name=\"py-TotalVariable\"\u003e\n \u003cDisplayName\u003epy-TotalVariable\u003c/DisplayName\u003e\n \u003cProperties/\u003e\n \u003cResourceURL\u003epy:myscript.py\u003c/ResourceURL\u003e\n \u003c/Script\u003e\n ```\n\n Since the resource URL is specified as `py:myscript.py`, which is invalid, the deployment of the API Proxy fails with the error: \n\n ```python\n Invalid resource url format. Resource url is py:myscript.py.\n ```\n\n### Resolution\n\nEnsure that the resource URL format specified in the `\u003cResourceURL\u003e` element of the PythonScript policy is valid. For example: \n\n```python\n\u003c?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?\u003e\n\u003cScript async=\"false\" continueOnError=\"false\" enabled=\"true\" timeLimit=\"200\" name=\"py-TotalVariable\"\u003e\n \u003cDisplayName\u003epy-TotalVariable\u003c/DisplayName\u003e\n \u003cProperties/\u003e\n \u003cResourceURL\u003epy://myscript.py\u003c/ResourceURL\u003e\n\u003c/Script\u003e\n```\n\nInvalidResourceUrlReference\n---------------------------\n\n### Error message\n\nDeployment of an API proxy through either the Apigee UI or API fails with this error message: \n\n```python\nError Deploying Revision revision_number to environment\nInvalid resource url ref invalid_reference in policy policy_name in org_name\n```\n\n### Example error message\n\n```python\nError Deploying Revision 2 to prod\nInvalid resource url ref py://myscript.py in policy Python_script in myorg\n```\n\n### Example screenshot\n\n### Cause\n\nIf the `\u003cResourceURL\u003e` and `\u003cIncludeURL\u003e` elements refer to a PythonScript file\nthat does not exist, then the deployment of the API proxy fails.\nIf you are deploying a proxy bundle from your local machine, then the PythonScript\nsource files must be stored under `/apiproxy/resources/py`(at the API proxy scope).\n\nIn the Apigee UI, the PythonScript source files appear under **py** in the Scripts section\nof the API proxy editor's Navigator pane as shown below:\n\nYou can also store resource files in [environment level repositories](/apigee/docs/api-platform/develop/resource-files) (to make PythonScript code available to all proxies in an env, for example). If any resource files specified in the policy cannot be found, then this error occurs.\n\n### Diagnosis\n\n1. Identify the PythonScript policy where the error occurred and the invalid resource URL reference. You can find this information from the error message. For example, in the following error, the policy name is `Python_script` and the invalid resource URL reference is `py://myscript.py`:\n\n ```python\n Invalid resource url ref py://myscript.py in policy Python_script in myorg\n ```\n2. Verify that the resource URL reference specified in the failed PythonScript policy matches with the value identified in the error message (step #1 above). For example, the following policy specifies the resource URL reference as `py://myscript.py`, which matches what's in the error message:\n\n ```python\n \u003c?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?\u003e\n \u003cScript async=\"false\" continueOnError=\"false\" enabled=\"true\" name=\"Python_script\"\u003e\n \u003cDisplayName\u003ePython-1\u003c/DisplayName\u003e\n \u003cProperties/\u003e\n \u003cResourceURL\u003epy://myscript.py\u003c/ResourceURL\u003e\n \u003c/Script\u003e\n ```\n3. Check if the file identified in step #1 file is part of the specific API Proxy bundle, or exists at the environment scope.\n\n 1. To check if the file is part of the specific API Proxy bundle, follow one of the below steps:\n 1. In the Apigee UI, check if this file is in the Scripts section of the API proxy.\n 2. Download the API Proxy bundle and search if the file exists.\n 2. If the file is not part of the specific API Proxy bundle, then check if it exists at the environment level. You can use the [Resource Files API](/apigee/docs/reference/apis/apigee/rest/v1/organizations.environments.resourcefiles) for this investigation.\n\n If the file does not exist at the API Proxy or environment level, then that's the cause of the error.\n\n In the example above, the invalid PythonScript filename is myscript.py. In the screenshot below, notice that the file specified as a resource URL in the policy does not appear in the Scripts section. Also the file does not exist at the environment level. Therefore, the deployment of the API Proxy fails with the error: \n\n ```python\n Invalid resource url ref py://myscript.py in policy Python_script in myorg\n ```\n\n### Resolution\n\nEnsure that the PythonScript files specified in `\u003cResourceURL\u003e` and `\u003cIncludeURL\u003e` elements refer to a valid file that exists at the API Proxy or environment level.\n\nTo correct the example PythonScript policy shown above, add the file myscript.py to the API Proxy bundle. In the screenshot below you can see that the PythonScript files specified in `\u003cResourceURL\u003e` and `\u003cIncludeURL\u003e` elements are visible in the Scripts section of the API Proxy bundle:"]]