Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

azure_rm_galleryimageversion_info throwing an exception when there are no versions #1434

Closed
christianmasopust opened this issue Feb 6, 2024 · 5 comments · Fixed by #1436
Closed
Labels
bug Something isn't working has_pr PR fixes have been made medium_priority Medium priority

Comments

@christianmasopust
Copy link

SUMMARY

azure_rm_galleryimageversion_info is failing with the following exception when there are no versions created for an image:

The full traceback is:
Traceback (most recent call last):
  File "/var/lib/awx/.ansible/tmp/ansible-tmp-1707215177.8060982-3649311-4710969984309/AnsiballZ_azure_rm_galleryimageversion_info.py", line 107, in <module>
    _ansiballz_main()
  File "/var/lib/awx/.ansible/tmp/ansible-tmp-1707215177.8060982-3649311-4710969984309/AnsiballZ_azure_rm_galleryimageversion_info.py", line 99, in _ansiballz_main
    invoke_module(zipped_mod, temp_path, ANSIBALLZ_PARAMS)
  File "/var/lib/awx/.ansible/tmp/ansible-tmp-1707215177.8060982-3649311-4710969984309/AnsiballZ_azure_rm_galleryimageversion_info.py", line 47, in invoke_module
    runpy.run_module(mod_name='ansible_collections.azure.azcollection.plugins.modules.azure_rm_galleryimageversion_info', init_globals=dict(_module_fqn='ansible_collections.azure.azcollection.plugins.modules.azure_rm_galleryimageversion_info', _modlib_path=modlib_path),
  File "/usr/lib64/python3.9/runpy.py", line 225, in run_module
    return _run_module_code(code, init_globals, run_name, mod_spec)
  File "/usr/lib64/python3.9/runpy.py", line 97, in _run_module_code
    _run_code(code, mod_globals, init_globals,
  File "/usr/lib64/python3.9/runpy.py", line 87, in _run_code
    exec(code, run_globals)
  File "/tmp/ansible_azure.azcollection.azure_rm_galleryimageversion_info_payload_7o7wq9qm/ansible_azure.azcollection.azure_rm_galleryimageversion_info_payload.zip/ansible_collections/azure/azcollection/plugins/modules/azure_rm_galleryimageversion_info.py", line 276, in <module>
  File "/tmp/ansible_azure.azcollection.azure_rm_galleryimageversion_info_payload_7o7wq9qm/ansible_azure.azcollection.azure_rm_galleryimageversion_info_payload.zip/ansible_collections/azure/azcollection/plugins/modules/azure_rm_galleryimageversion_info.py", line 272, in main
  File "/tmp/ansible_azure.azcollection.azure_rm_galleryimageversion_info_payload_7o7wq9qm/ansible_azure.azcollection.azure_rm_galleryimageversion_info_payload.zip/ansible_collections/azure/azcollection/plugins/modules/azure_rm_galleryimageversion_info.py", line 145, in __init__
  File "/tmp/ansible_azure.azcollection.azure_rm_galleryimageversion_info_payload_7o7wq9qm/ansible_azure.azcollection.azure_rm_galleryimageversion_info_payload.zip/ansible_collections/azure/azcollection/plugins/module_utils/azure_rm_common.py", line 446, in __init__
  File "/tmp/ansible_azure.azcollection.azure_rm_galleryimageversion_info_payload_7o7wq9qm/ansible_azure.azcollection.azure_rm_galleryimageversion_info_payload.zip/ansible_collections/azure/azcollection/plugins/modules/azure_rm_galleryimageversion_info.py", line 163, in exec_module
  File "/tmp/ansible_azure.azcollection.azure_rm_galleryimageversion_info_payload_7o7wq9qm/ansible_azure.azcollection.azure_rm_galleryimageversion_info_payload.zip/ansible_collections/azure/azcollection/plugins/modules/azure_rm_galleryimageversion_info.py", line 257, in listbygalleryimage
  File "/tmp/ansible_azure.azcollection.azure_rm_galleryimageversion_info_payload_7o7wq9qm/ansible_azure.azcollection.azure_rm_galleryimageversion_info_payload.zip/ansible_collections/azure/azcollection/plugins/modules/azure_rm_galleryimageversion_info.py", line 257, in <listcomp>
  File "/tmp/ansible_azure.azcollection.azure_rm_galleryimageversion_info_payload_7o7wq9qm/ansible_azure.azcollection.azure_rm_galleryimageversion_info_payload.zip/ansible_collections/azure/azcollection/plugins/modules/azure_rm_galleryimageversion_info.py", line 261, in format_item
KeyError: 'id'

ISSUE TYPE
  • Bug Report
COLLECTION VERSION

2.1.1

OS / ENVIRONMENT

RHEL 9

STEPS TO REPRODUCE

query image version of an image that don't have versions created so far

EXPECTED RESULTS

empty list?

ACTUAL RESULTS

Exception thrown

@Fred-sun Fred-sun added bug Something isn't working has_pr PR fixes have been made medium_priority Medium priority labels Feb 7, 2024
@Fred-sun
Copy link
Collaborator

Fred-sun commented Feb 7, 2024

@christianmasopust Thank you for submitting the problem. It has fixed in #1436!

@christianmasopust
Copy link
Author

wow.... that was fast... Thanks a lot!

@christianmasopust
Copy link
Author

christianmasopust commented Feb 8, 2024

@Fred-sun Are you sure about the fix? I've tried it here (now with collection version 2.2.0) but it still does not work.

Looking at the "item" in function format_item shows that it always has some content, when there is no version found the item is:

{'value': []}

And, I'm not sure that format_item should return None. If it does, the result of azure_rm_galleryimageversion_info would be:

ok: [localhost] => {
    "gallery_image_version_info": {
        "changed": false,
        "failed": false,
        "versions": [
            null
        ]
    }
}

and that would give 1 as the length of the versions list

@christianmasopust
Copy link
Author

christianmasopust commented Feb 9, 2024

A similar issue is when trying to get the image version information of a none existing version, here (with the above fix) it would return:

ok: [localhost] => {
    "gallery_image_version_info": {
        "changed": false,
        "failed": false,
        "versions": null
    }
}

which also may be wrong. shouldn't "versions" then be an empty list instead of null?

@Fred-sun
Copy link
Collaborator

@christianmasopust Did you update to the branch you changed in #1346? This change is still under review and has not been released, if you want to test, please update the #1346 branch code test, thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working has_pr PR fixes have been made medium_priority Medium priority
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants