aglinxinyuan commented on code in PR #5922:
URL: https://github.com/apache/texera/pull/5922#discussion_r3489179082
##########
amber/src/main/scala/org/apache/texera/web/service/WorkflowService.scala:
##########
@@ -277,14 +275,12 @@ class WorkflowService(
}
}
}
- // Once the execution is published via `executionService.onNext`, the
normal
- // state-store path surfaces fatal errors to the UI: `errorHandler` writes
- // them into `executionStateStore.metadataStore`, whose diff handler (set
up
- // in the WorkflowExecutionService constructor) emits a WorkflowErrorEvent
- // that `connectToExecution` forwards. Before that point, neither the
emitter
- // nor a subscriber exists yet, so a failure in the constructor itself
would
- // be recorded but never reach the frontend -- see the fallback in `catch`.
- var executionPublished = false
+ // WorkflowExecutionService construction does no external work and cannot
+ // throw; it registers its error/state diff handler up front. Once
published
+ // via `executionService.onNext`, any failure in `executeWorkflow()` is
+ // recorded by `errorHandler` into the metadata store, whose handler emits
a
+ // WorkflowErrorEvent that `connectToExecution` forwards -- a single
+ // reporting site, no separate pre-publish fallback needed.
Review Comment:
Done in `573322c0` — trimmed the comment to just the mechanism (handler
registered first → `executeWorkflow` failures recorded by `errorHandler` → diff
handler emits the event), dropping the "single reporting site / no pre-publish
fallback" framing. Applied the same trim to the matching comment in
`WorkflowExecutionService`.
_🤖 Addressed by [Claude Code](https://claude.com/claude-code)_
##########
amber/src/test/scala/org/apache/texera/web/service/WorkflowExecutionServiceSpec.scala:
##########
@@ -0,0 +1,112 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.texera.web.service
+
+import com.google.protobuf.timestamp.Timestamp
+import org.apache.texera.amber.core.workflow.{WorkflowContext,
WorkflowSettings}
+import
org.apache.texera.amber.core.workflowruntimestate.FatalErrorType.EXECUTION_FAILURE
+import org.apache.texera.amber.core.workflowruntimestate.WorkflowFatalError
+import
org.apache.texera.amber.engine.architecture.rpc.controlreturns.WorkflowAggregatedState.RUNNING
+import org.apache.texera.web.model.websocket.event.{
+ TexeraWebSocketEvent,
+ WorkflowErrorEvent,
+ WorkflowStateEvent
+}
+import org.apache.texera.web.model.websocket.request.{LogicalPlanPojo,
WorkflowExecuteRequest}
+import org.apache.texera.web.storage.ExecutionStateStore
+import org.scalatest.flatspec.AnyFlatSpec
+import org.scalatest.matchers.should.Matchers
+
+import java.net.URI
+import java.time.Instant
+import scala.collection.mutable
+
+/**
+ * Regression guard for the consolidated init-error reporting path (#5921):
+ * `WorkflowExecutionService` registers its metadata-store diff handler at
+ * construction, so a fatalErrors update -- e.g. the one `errorHandler`
records
+ * when `executeWorkflow` fails -- surfaces as a `WorkflowErrorEvent` through
the
+ * normal websocket-event observable, with no separate pre-publish fallback.
+ *
+ * The unused `controllerConfig` / `resultService` are passed as `null` on
+ * purpose: construction must stay side-effect-free (all throwing work is in
+ * `executeWorkflow`), so a future change that dereferences them during
+ * construction would fail here.
+ */
+class WorkflowExecutionServiceSpec extends AnyFlatSpec with Matchers {
+
+ private def buildService(store: ExecutionStateStore):
WorkflowExecutionService = {
+ val request = WorkflowExecuteRequest(
+ executionName = "test",
+ engineVersion = "test",
+ logicalPlan = LogicalPlanPojo(List.empty, List.empty, List.empty,
List.empty),
+ replayFromExecution = None,
+ workflowSettings = WorkflowSettings(),
+ emailNotificationEnabled = false,
+ computingUnitId = 0
+ )
+ new WorkflowExecutionService(
+ null,
+ new WorkflowContext(),
+ null,
+ request,
+ store,
+ (_: Throwable) => (),
+ None,
+ new URI("vfs:///test")
+ )
+ }
+
+ /** Subscribe to the metadata store's websocket-event stream and collect
events. */
+ private def collectEvents(
+ store: ExecutionStateStore
+ ): mutable.ArrayBuffer[TexeraWebSocketEvent] = {
+ val events = mutable.ArrayBuffer.empty[TexeraWebSocketEvent]
+ store.metadataStore.getWebsocketEventObservable.subscribe {
+ (evts: Iterable[TexeraWebSocketEvent]) => events ++= evts
+ }
+ events
+ }
+
+ "WorkflowExecutionService" should
+ "surface a recorded fatal error as a WorkflowErrorEvent via the
metadata-store handler" in {
Review Comment:
Added in `573322c0` — a new case "report fatal errors recorded at successive
phases through the same handler" wires up the same recording `errorHandler`
that `WorkflowService` builds (the one the service invokes at the compile /
runtime-creation / `startWorkflow` phases), invokes it for an init-phase error
and a runtime-phase error, and asserts both surface as `WorkflowErrorEvent`s
through the construction-registered diff handler. All 3 cases pass via
`WorkflowExecutionService/testOnly ...WorkflowExecutionServiceSpec`.
_🤖 Addressed by [Claude Code](https://claude.com/claude-code)_
--
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]