From 19613ce1119414e405883c990065d5cc2d08939f Mon Sep 17 00:00:00 2001 From: "patchback[bot]" <45432694+patchback[bot]@users.noreply.github.com> Date: Sun, 1 Sep 2024 20:55:19 +0200 Subject: [PATCH] [PR #8794/249126f4 backport][stable-9] proxmox inventory: fixing possible concatenation error (#8818) proxmox inventory: fixing possible concatenation error (#8794) * Fixing possible concatination error * Create 8794-Fixing-possible-concatination-error.yaml * Update 8794-Fixing-possible-concatination-error.yaml Updating changelog (cherry picked from commit 249126f42972edd1ec427c777588b9d5ccf4bfbb) Co-authored-by: Simon Siebert --- .../fragments/8794-Fixing-possible-concatination-error.yaml | 2 ++ plugins/inventory/proxmox.py | 5 +++-- 2 files changed, 5 insertions(+), 2 deletions(-) create mode 100644 changelogs/fragments/8794-Fixing-possible-concatination-error.yaml diff --git a/changelogs/fragments/8794-Fixing-possible-concatination-error.yaml b/changelogs/fragments/8794-Fixing-possible-concatination-error.yaml new file mode 100644 index 0000000000..a94eace415 --- /dev/null +++ b/changelogs/fragments/8794-Fixing-possible-concatination-error.yaml @@ -0,0 +1,2 @@ +bugfixes: + - proxmox inventory plugin - fixed a possible error on concatenating responses from proxmox. In case an API call unexpectedly returned an empty result, the inventory failed with a fatal error. Added check for empty response (https://github.com/ansible-collections/community.general/issues/8798, https://github.com/ansible-collections/community.general/pull/8794). diff --git a/plugins/inventory/proxmox.py b/plugins/inventory/proxmox.py index a4b05b57ed..edfadfd8ad 100644 --- a/plugins/inventory/proxmox.py +++ b/plugins/inventory/proxmox.py @@ -329,8 +329,9 @@ class InventoryModule(BaseInventoryPlugin, Constructable, Cacheable): data = json['data'] break else: - # /hosts 's 'results' is a list of all hosts, returned is paginated - data = data + json['data'] + if json['data']: + # /hosts 's 'results' is a list of all hosts, returned is paginated + data = data + json['data'] break self._cache[self.cache_key][url] = data