diff --git a/changelogs/fragments/702-docker-volume-label-none.yaml b/changelogs/fragments/702-docker-volume-label-none.yaml new file mode 100644 index 000000000..d1c9c8471 --- /dev/null +++ b/changelogs/fragments/702-docker-volume-label-none.yaml @@ -0,0 +1,2 @@ +bugfixes: + - docker_volume - fix crash caused by accessing an empty dictionary. The ``has_different_config()`` was raising an ``AttributeError`` because the ``self.existing_volume["Labels"]`` dictionary was ``None`` (https://github.com/ansible-collections/community.docker/pull/702). diff --git a/plugins/modules/docker_volume.py b/plugins/modules/docker_volume.py index 3932eacf6..7831bf987 100644 --- a/plugins/modules/docker_volume.py +++ b/plugins/modules/docker_volume.py @@ -209,7 +209,7 @@ def has_different_config(self): parameter=value, active=self.existing_volume['Options'].get(key)) if self.parameters.labels: - existing_labels = self.existing_volume.get('Labels', {}) + existing_labels = self.existing_volume.get('Labels') or {} for label in self.parameters.labels: if existing_labels.get(label) != self.parameters.labels.get(label): differences.add('labels.%s' % label,