From b836ed665b6c02ed1fd21fc35380e49c7cdd0555 Mon Sep 17 00:00:00 2001
From: Charlotte Hausman <chausman@nrao.edu>
Date: Wed, 3 Aug 2022 10:44:08 -0400
Subject: [PATCH] fix pass/fail with mutable version bug

---
 .../workspaces/capability/schema.py           | 22 +++++++++++++------
 1 file changed, 15 insertions(+), 7 deletions(-)

diff --git a/shared/workspaces/workspaces/capability/schema.py b/shared/workspaces/workspaces/capability/schema.py
index e0edc8359..f65593272 100644
--- a/shared/workspaces/workspaces/capability/schema.py
+++ b/shared/workspaces/workspaces/capability/schema.py
@@ -539,15 +539,23 @@ class QaPass(Action):
     @staticmethod
     def check_still_running(version: CapabilityVersion) -> bool:
         workflow_service_url = CapoConfig().settings(WORKFLOW_SETTINGS_KEY).serviceUrl
-        if version.current_execution.current_workflow_request_id:
-            response = requests.get(
-                f"{workflow_service_url}/workflows/{version.capability.name}/requests/"
-                f"{version.current_execution.current_workflow_request_id}/htcondor_id"
-            )
-            if json.loads(response.content.decode())["htcondor_job_id"] == "None":
+        # check for execution
+        if version.current_execution:
+            # version is submitted, check for workflow
+            if version.current_execution.current_workflow_request_id:
+                response = requests.get(
+                    f"{workflow_service_url}/workflows/{version.capability.name}/requests/"
+                    f"{version.current_execution.current_workflow_request_id}/htcondor_id"
+                )
+                if json.loads(response.content.decode())["htcondor_job_id"] == "None":
+                    # not running in HTCondor
+                    return False
+                return True
+            else:
+                # workflow not submitted
                 return False
-            return True
         else:
+            # version is not submitted
             return False
 
     @staticmethod
-- 
GitLab