diff --git a/changelogs/fragments/273-Dont_call_get_on_None.yaml b/changelogs/fragments/273-Dont_call_get_on_None.yaml new file mode 100644 index 00000000..afb16d0a --- /dev/null +++ b/changelogs/fragments/273-Dont_call_get_on_None.yaml @@ -0,0 +1,2 @@ +bugfixes: + - digital_ocean_droplet - if the JSON response lacks a key and the associated variable is set to ``None``, then don't treat that variable like a ``dict`` and call ``get()`` on it without first testing it (https://github.com/ansible-collections/community.digitalocean/issues/272). diff --git a/plugins/modules/digital_ocean_droplet.py b/plugins/modules/digital_ocean_droplet.py index 14f4e35a..791f2891 100644 --- a/plugins/modules/digital_ocean_droplet.py +++ b/plugins/modules/digital_ocean_droplet.py @@ -542,7 +542,7 @@ def wait_status(self, droplet_id, desired_statuses): status_code = response.status_code message = json_data.get("message", "no error message") droplet = json_data.get("droplet", None) - droplet_status = droplet.get("status", None) + droplet_status = droplet.get("status", None) if droplet else None if droplet is None or droplet_status is None: self.module.fail_json(