Xiao-zhen-Liu commented on code in PR #9015:
URL: https://github.com/apache/texera/pull/9015#discussion_r4673056297


##########
amber/src/test/scala/org/apache/texera/amber/engine/architecture/scheduling/WorkflowExecutionManagerSpec.scala:
##########
@@ -213,7 +213,8 @@ class WorkflowExecutionManagerSpec
             errorMessage = udfInitError,
             errorDetails = "",
             stackTrace = "",
-            language = ErrorLanguage.PYTHON
+            language = ErrorLanguage.PYTHON,
+            None

Review Comment:
   Nit: naming this argument would match the four named arguments above it.
   ```suggestion
               relatedWorkerId = None
   ```



##########
amber/src/test/scala/org/apache/texera/amber/engine/architecture/scheduling/RegionExecutionManagerSpec.scala:
##########
@@ -683,6 +683,7 @@ class RegionExecutionManagerSpec
       errorMessage = "transient EndWorker failure",
       errorDetails = "",
       stackTrace = "",
-      language = ErrorLanguage.SCALA
+      language = ErrorLanguage.SCALA,
+      None

Review Comment:
   Nit: the four arguments above are named, so a bare value here does not say 
which field it fills.
   ```suggestion
         relatedWorkerId = None
   ```



##########
amber/src/test/scala/org/apache/texera/amber/error/ErrorUtilsSpec.scala:
##########
@@ -204,4 +208,50 @@ class ErrorUtilsSpec extends AnyFlatSpec with Matchers {
     operatorId shouldBe "__DummyOperator"
     workerId shouldBe "COORDINATOR"
   }
+
+  // ----- carrying the failing worker through ControlError -----
+
+  private val failingWorker =
+    ActorVirtualIdentity("Worker:WF23-PythonUDFV2-operator-udfdemo-main-0")
+
+  "mkControlError with a WorkflowRuntimeException" should "carry the failing 
worker" in {
+    val ce = ErrorUtils.mkControlError(new WorkflowRuntimeException("boom", 
Some(failingWorker)))
+    ce.relatedWorkerId shouldBe Some(failingWorker)
+  }
+
+  it should "leave the worker empty for errors that are not tied to one" in {
+    ErrorUtils.mkControlError(new RuntimeException("boom")).relatedWorkerId 
shouldBe None
+    ErrorUtils
+      .mkControlError(new WorkflowRuntimeException("boom", None))
+      .relatedWorkerId shouldBe None
+  }
+
+  "reconstructThrowable with a related worker" should "rebuild a 
WorkflowRuntimeException" in {
+    val original =
+      new WorkflowRuntimeException("boom", new IllegalStateException("root"), 
Some(failingWorker))
+    val rebuilt = 
ErrorUtils.reconstructThrowable(ErrorUtils.mkControlError(original))
+    rebuilt shouldBe a[WorkflowRuntimeException]
+    val wre = rebuilt.asInstanceOf[WorkflowRuntimeException]
+    wre.relatedWorkerId shouldBe Some(failingWorker)
+    wre.getMessage shouldBe "boom"
+    wre.getCause.getMessage shouldBe new IllegalStateException("root").toString
+  }
+
+  it should "let the error be attributed to the failing operator" in {
+    // WorkflowService reads relatedWorkerId from the rebuilt error; before 
this,
+    // the worker was dropped and the UI showed "unknown operator".
+    val rebuilt = ErrorUtils
+      .reconstructThrowable(
+        ErrorUtils.mkControlError(new WorkflowRuntimeException("boom", 
Some(failingWorker)))
+      )
+      .asInstanceOf[WorkflowRuntimeException]
+    ErrorUtils.getOperatorFromActorIdOpt(rebuilt.relatedWorkerId) shouldBe
+      ("PythonUDFV2-operator-udfdemo", failingWorker.name)
+  }
+
+  it should "still rebuild a plain Throwable when no worker is set" in {

Review Comment:
   Nit: this case sits under the heading for an error with a related worker, so 
its full test name contradicts what it checks. Giving it its own heading would 
make the test name match its case.



-- 
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