surahman commented on a change in pull request #3786:
URL: https://github.com/apache/incubator-heron/pull/3786#discussion_r836005466



##########
File path: heron/tools/ui/src/python/main.py
##########
@@ -316,17 +347,25 @@ class ApiEnvelope(pydantic.BaseModel):
   executiontime: int
   result: dict
 
-
 def api_topology_json(method: Callable[[], dict]) -> ApiEnvelope:
   """Wrap the output of a method with a response envelope."""
   started = time.time()
   result = method()
-  return ApiEnvelope(
-      status="success",
-      message="",
-      executiontime=time.time() - started,
-      result=result,
-  )
+  Log.debug(f"Api topology: {result}")
+  if type(result) is None:
+    return ApiEnvelope(
+        status="failure",
+        message="No topology found",
+        executiontime=time.time() - started,
+        result={},
+    )
+  else:
+    return ApiEnvelope(
+        status="success",
+        message="",
+        executiontime=time.time() - started,
+        result=result,
+    )

Review comment:
       The call to `api_topology_list_json` makes a lambda call to 
`get_component_exceptions` here:
   
https://github.com/apache/incubator-heron/blob/f417981fa33c9a1d9990e41a241878898adcb928/heron/tools/ui/src/python/main.py#L446-L447
   
   The `get_component_exceptions` can return a type of `Any`, which in turn 
includes `None`.
   
https://github.com/apache/incubator-heron/blob/af7053ec8162ec43ea7b58d4ddf746ff2b2ab43d/heron/tools/common/src/python/clients/tracker.py#L250-L266
   
   If you would like to handle a `None` return type by returning a `failure` 
status then your suggestion is correct. I will push the change.




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to