From e083184d9f913e8d54a7bb1deb610b8860526e19 Mon Sep 17 00:00:00 2001 From: Eric Ball Date: Wed, 28 Jul 2021 06:33:12 -0700 Subject: [PATCH] Fix: Add check for "stopped" before reading text nexus.release_staging_repo has an error condition if the staging repo is not released when checked, as a non-existent "stopped" field will return a NoneType, causing an error when .text is read. We avoid this by checking for the existence of the "stopped" field before attempting to read the text. Issue: RELENG-3813 Change-Id: I0fae854a3ee52118806f70ea8b6faacc5fda430b Signed-off-by: Eric Ball --- lftools/nexus/cmd.py | 4 ++-- releasenotes/notes/fix-release-no-attribute-45a84f852233ef36.yaml | 6 ++++++ 2 files changed, 8 insertions(+), 2 deletions(-) create mode 100644 releasenotes/notes/fix-release-no-attribute-45a84f852233ef36.yaml diff --git a/lftools/nexus/cmd.py b/lftools/nexus/cmd.py index d2d6c1f4..83cb222c 100644 --- a/lftools/nexus/cmd.py +++ b/lftools/nexus/cmd.py @@ -516,8 +516,8 @@ def release_staging_repos(repos, verify, nexus_url=""): events = root.findall("./stagingActivity") for event in events: name = event.find("name") - if name.text == "release": - stopped = event.find("stopped") + stopped = event.find("stopped") + if name.text == "release" and stopped is not None: log.info("Repo released at: {}".format(stopped.text)) released = True if not released: diff --git a/releasenotes/notes/fix-release-no-attribute-45a84f852233ef36.yaml b/releasenotes/notes/fix-release-no-attribute-45a84f852233ef36.yaml new file mode 100644 index 00000000..350947ba --- /dev/null +++ b/releasenotes/notes/fix-release-no-attribute-45a84f852233ef36.yaml @@ -0,0 +1,6 @@ +--- +fixes: + - | + Add check for "stopped" event property before reading property text in + nexus.release_staging_repo, in order to avoid possible missing attribute + error. -- 2.16.6