From da2dfd0706112625e8762a81f2cc1bd7c08a1aed Mon Sep 17 00:00:00 2001 From: Kirill Petrov Date: Tue, 17 May 2022 08:45:10 +0300 Subject: [PATCH] gitlab_hook: use None for non-existent attr in gitlab API response (#4668) * gitlab_hook: use empty string for non-existent attr in gitlab API response; * gitlab_hook: use None for non-existent attr in gitlab API response; * gitlab_hook: use None for non-existent attr in gitlab API response - add changelog fragment; * gitlab_hook: update changelog fragment for #4668 * Update changelogs/fragments/4668-gitlab_hook-use-None-for-non-existent-attr.yml Co-authored-by: Felix Fontein --- .../4668-gitlab_hook-use-None-for-non-existent-attr.yml | 2 ++ plugins/modules/source_control/gitlab/gitlab_hook.py | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) create mode 100644 changelogs/fragments/4668-gitlab_hook-use-None-for-non-existent-attr.yml diff --git a/changelogs/fragments/4668-gitlab_hook-use-None-for-non-existent-attr.yml b/changelogs/fragments/4668-gitlab_hook-use-None-for-non-existent-attr.yml new file mode 100644 index 0000000000..45a3f9f0b9 --- /dev/null +++ b/changelogs/fragments/4668-gitlab_hook-use-None-for-non-existent-attr.yml @@ -0,0 +1,2 @@ +bugfixes: + - gitlab_hook - avoid errors during idempotency check when an attribute does not exist (https://github.com/ansible-collections/community.general/pull/4668). diff --git a/plugins/modules/source_control/gitlab/gitlab_hook.py b/plugins/modules/source_control/gitlab/gitlab_hook.py index cd6d2a3031..8a850b1c9e 100644 --- a/plugins/modules/source_control/gitlab/gitlab_hook.py +++ b/plugins/modules/source_control/gitlab/gitlab_hook.py @@ -257,7 +257,7 @@ class GitLabHook(object): for arg_key, arg_value in arguments.items(): if arguments[arg_key] is not None: - if getattr(hook, arg_key) != arguments[arg_key]: + if getattr(hook, arg_key, None) != arguments[arg_key]: setattr(hook, arg_key, arguments[arg_key]) changed = True