You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am trying to generate schema from Open API json (Nutanix subnet API) and it gives me UnboundLocalError: local variable 'post_properties' referenced before assignment error.
~/work/codebase/codegen/content_builder ❯ ansible-playbook build.yaml -e manifest_file=manifest.yaml ansible1 12:05:08 PM
[WARNING]: No inventory was parsed, only implicit localhost is available
[WARNING]: provided hosts list is empty, only localhost is available. Note that the implicit localhost does not match 'all'
PLAY [localhost] *********************************************************************************************************************************************
TASK [Gathering Facts] ***************************************************************************************************************************************
ok: [localhost]
TASK [ansible.content_builder.run : Validate task input against defined schema] ******************************************************************************
ok: [localhost]
TASK [ansible.content_builder.run : Load settings from manifest file] ****************************************************************************************
ok: [localhost]
TASK [Start scaffolding] *************************************************************************************************************************************
TASK [ansible.content_builder.init : Create the collection directory structure] ******************************************************************************
ok: [localhost] => (item=plugins/modules)
ok: [localhost] => (item=plugins/module_utils)
ok: [localhost] => (item=plugins/module_utils/common/)
ok: [localhost] => (item=plugins/plugin_utils)
ok: [localhost] => (item=plugins/lookup)
ok: [localhost] => (item=plugins/filter)
ok: [localhost] => (item=plugins/action)
ok: [localhost] => (item=plugins/inventory)
ok: [localhost] => (item=plugins/cache)
ok: [localhost] => (item=plugins/test)
ok: [localhost] => (item=docs)
ok: [localhost] => (item=meta)
ok: [localhost] => (item=tests)
TASK [ansible.content_builder.init : Touch the __init__.py in each directory] ********************************************************************************
ok: [localhost] => (item=plugins/modules)
ok: [localhost] => (item=plugins/module_utils)
ok: [localhost] => (item=plugins/module_utils/common/)
ok: [localhost] => (item=plugins/plugin_utils)
ok: [localhost] => (item=plugins/lookup)
ok: [localhost] => (item=plugins/filter)
ok: [localhost] => (item=plugins/action)
ok: [localhost] => (item=plugins/inventory)
ok: [localhost] => (item=plugins/cache)
ok: [localhost] => (item=plugins/test)
ok: [localhost] => (item=docs)
ok: [localhost] => (item=meta)
ok: [localhost] => (item=tests)
TASK [ansible.content_builder.init : Add license file to collection (default is gpl-3.0)] ********************************************************************
ok: [localhost]
TASK [ansible.content_builder.init : Add readme to collection] ***********************************************************************************************
ok: [localhost] => (item={'source': 'README.md.j2', 'destination': '/Users/pradeep.bhati/work/codebase/codegen/content_builder/README.md'})
ok: [localhost] => (item={'source': 'galaxy.yaml.j2', 'destination': '/Users/pradeep.bhati/work/codebase/codegen/content_builder/galaxy.yml'})
TASK [ansible.content_builder.init : Create the collection directory structure] ******************************************************************************
ok: [localhost] => (item=plugins/modules)
ok: [localhost] => (item=plugins/action)
ok: [localhost] => (item=tests)
TASK [ansible.content_builder.scaffold_plugins : Scaffold the specified plugins] *****************************************************************************
included: /Users/pradeep.bhati/.ansible/collections/ansible_collections/ansible/content_builder/roles/scaffold_plugins/tasks/template.yml for localhost => (item={'type': 'module_openapi', 'name': 'subnets', 'module_version': '1.0.0', 'rm_swagger_json': '/Users/pradeep.bhati/Downloads/openapi3_0.json', 'api_object_path': '/networking/v4.0.b1/config/subnets', 'resource': 'subnets', 'unique_key': '', 'author': 'pradeep.bhati@nutanix.com'})
TASK [ansible.content_builder.scaffold_plugins : Debug message] **********************************************************************************************
ok: [localhost] => {
"msg": "Scaffolding subnets of type module_openapi"
}
TASK [ansible.content_builder.scaffold_plugins : Set facts] **************************************************************************************************
ok: [localhost]
TASK [ansible.content_builder.scaffold_plugins : Set path to main plugin file for generic plugins] ***********************************************************
skipping: [localhost]
TASK [ansible.content_builder.scaffold_plugins : Set path to main plugin file for specialized plugins] *******************************************************
ok: [localhost]
TASK [ansible.content_builder.scaffold_plugins : Load docstring (if specified)] ******************************************************************************
skipping: [localhost]
TASK [ansible.content_builder.scaffold_plugins : Load examples from example file (if specified)] *************************************************************
skipping: [localhost]
TASK [ansible.content_builder.scaffold_plugins : Check to see if the plugin file exists] *********************************************************************
ok: [localhost]
TASK [ansible.content_builder.scaffold_plugins : Check if documentation string can be found] *****************************************************************
skipping: [localhost]
TASK [ansible.content_builder.scaffold_plugins : Extract documentation from plugin (for existing plugin)] ****************************************************
skipping: [localhost]
TASK [ansible.content_builder.scaffold_plugins : Fail if no docstring could be found] ************************************************************************
skipping: [localhost]
TASK [ansible.content_builder.scaffold_plugins : Extract examples from plugin (for existing plugin)] *********************************************************
skipping: [localhost]
TASK [Start scaffolding specialized plugin] ******************************************************************************************************************
TASK [Generate security content] *****************************************************************************************************************************
TASK [ansible.content_builder.module_openapi_security : Get the CURRENT WORKING DIR] *************************************************************************
ok: [localhost]
TASK [ansible.content_builder.module_openapi_security : Create temporary build directory] ********************************************************************
changed: [localhost]
TASK [ansible.content_builder.module_openapi_security : EXECUTE the python script] ***************************************************************************
fatal: [localhost -> 127.0.0.1]: FAILED! => {"changed": false, "cmd": ["python3", "/Users/pradeep.bhati/.ansible/collections/ansible_collections/ansible/content_builder/roles/module_openapi_security/templates/doc_generator.py", "/Users/pradeep.bhati/Downloads/openapi3_0.json", "/networking/v4.0.b1/config/subnets", "subnets", "1.0.0", "subnets", "nutanix", "ncp", "", "pradeep.bhati@nutanix.com", "/var/folders/4w/z2gbpknj63zd_mx6003hhpjh0000gp/T/ansible.qjnr_fm0build"], "delta": "0:00:00.167435", "end": "2023-11-10 12:09:39.275832", "msg": "non-zero return code", "rc": 1, "start": "2023-11-10 12:09:39.108397", "stderr": "Traceback (most recent call last):\n File \"/Users/pradeep.bhati/.ansible/collections/ansible_collections/ansible/content_builder/roles/module_openapi_security/templates/doc_generator.py\", line 914, in <module>\n main()\n File \"/Users/pradeep.bhati/.ansible/collections/ansible_collections/ansible/content_builder/roles/module_openapi_security/templates/doc_generator.py\", line 904, in main\n post_properties,\nUnboundLocalError: local variable 'post_properties' referenced before assignment", "stderr_lines": ["Traceback (most recent call last):", " File \"/Users/pradeep.bhati/.ansible/collections/ansible_collections/ansible/content_builder/roles/module_openapi_security/templates/doc_generator.py\", line 914, in <module>", " main()", " File \"/Users/pradeep.bhati/.ansible/collections/ansible_collections/ansible/content_builder/roles/module_openapi_security/templates/doc_generator.py\", line 904, in main", " post_properties,", "UnboundLocalError: local variable 'post_properties' referenced before assignment"], "stdout": "", "stdout_lines": []}
NO MORE HOSTS LEFT *******************************************************************************************************************************************
PLAY RECAP ***************************************************************************************************************************************************
localhost : ok=15 changed=1 unreachable=0 failed=1 skipped=7 rescued=0 ignored=0
EXPECTED RESULTS
Code generation should go fine.
ACTUAL RESULTS
Failing with error as above.
The text was updated successfully, but these errors were encountered:
bhati-pradeep
changed the title
Facing UnboundLocalError: local variable 'post_properties' referenced before assignment while creating modules from open API
Facing UnboundLocalError: local variable 'post_properties' referenced before assignment while creating schema from open API
Nov 10, 2023
SUMMARY
I am trying to generate schema from Open API json (Nutanix subnet API) and it gives me
UnboundLocalError: local variable 'post_properties' referenced before assignment
error.Error is coming from :
ansible.content_builder/roles/module_openapi_security/templates/doc_generator.py
Line 904 in 1a8071e
ISSUE TYPE
COMPONENT NAME
module_openapi
ANSIBLE VERSION
CONFIGURATION
OS / ENVIRONMENT
Mac OS Monterey
STEPS TO REPRODUCE
Create build.yaml and manifest.yaml as per below files.
Download open api yaml from https://developers.nutanix.com/api/v1/namespaces/networking/versions/v4.0.b1/yaml and convert it using https://editor-next.swagger.io/ to json format.
build.yaml
manifest.yaml
Error:
EXPECTED RESULTS
Code generation should go fine.
ACTUAL RESULTS
Failing with error as above.
The text was updated successfully, but these errors were encountered: