From: Eric Ball Date: Wed, 28 Jul 2021 13:33:12 +0000 (-0700) Subject: Fix: Add check for "stopped" before reading text X-Git-Tag: v0.35.5^0 X-Git-Url: https://gerrit.linuxfoundation.org/infra/gitweb?a=commitdiff_plain;h=refs%2Fchanges%2F52%2F68352%2F5;p=releng%2Flftools.git 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 --- 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.