From 11fcf661bfabd1809f80a4fa289d377b23ad34cd Mon Sep 17 00:00:00 2001 From: Josh Date: Mon, 20 Dec 2021 14:00:49 -0500 Subject: [PATCH] fix gitlab_project avatar_path open when undefined bug (#3926) (#3927) * fix gitlab_project avatar_path open when undefined bug (#3926) * remove changelog fragment --- plugins/modules/source_control/gitlab/gitlab_project.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/plugins/modules/source_control/gitlab/gitlab_project.py b/plugins/modules/source_control/gitlab/gitlab_project.py index b29c38c0e9..ca17861bbf 100644 --- a/plugins/modules/source_control/gitlab/gitlab_project.py +++ b/plugins/modules/source_control/gitlab/gitlab_project.py @@ -299,10 +299,11 @@ class GitLabProject(object): project = self.create_project(namespace, project_options) # add avatar to project - try: - project.avatar = open(options['avatar_path'], 'rb') - except IOError as e: - self._module.fail_json(msg='Cannot open {0}: {1}'.format(options['avatar_path'], e)) + if options['avatar_path']: + try: + project.avatar = open(options['avatar_path'], 'rb') + except IOError as e: + self._module.fail_json(msg='Cannot open {0}: {1}'.format(options['avatar_path'], e)) changed = True else: