Fix: Add check for "stopped" before reading text 52/68352/5 v0.35.5
authorEric Ball <eball@linuxfoundation.org>
Wed, 28 Jul 2021 13:33:12 +0000 (06:33 -0700)
committerEric Ball <eball@linuxfoundation.org>
Wed, 28 Jul 2021 15:08:13 +0000 (08:08 -0700)
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 <eball@linuxfoundation.org>
lftools/nexus/cmd.py
releasenotes/notes/fix-release-no-attribute-45a84f852233ef36.yaml [new file with mode: 0644]

index d2d6c1f..83cb222 100644 (file)
@@ -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 (file)
index 0000000..350947b
--- /dev/null
@@ -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.