This is an automated email from the ASF dual-hosted git repository. github-merge-queue[bot] pushed a commit to branch gh-readonly-queue/main/pr-8969-b516b2c65b3293887cafd03d92145b0283bb8328 in repository https://gitbox.apache.org/repos/asf/texera.git
commit f80f6f79b3b060be7051b672fd549d99afb9b56d Author: Eugene Gu <[email protected]> AuthorDate: Mon Nov 16 05:29:03 2026 +0000 fix(amber): reject reconfiguration of unsupported operators (#8969) ### What changes were proposed in this PR? **Root cause.** `ExecutionReconfigurationService.modifyOperatorLogic` matches the `Try` returned by the operator's `runtimeReconfiguration` and answers a `Failure` with `ModifyLogicResponse(isValid = false)`. But the `LogicalOp` base implementation throws `UnsupportedOperationException` instead of returning `Failure`, so for an operator that advertises `supportReconfiguration = true` without an override (`PythonLambdaFunctionOpDesc`, `HuggingFaceSentimentAnalysisOpDesc`, `PythonUDFSourceOpDescV2`) the exception escapes to the websocket catch-all, is recorded as a `COMPILATION_ERROR` fatal error, and the frontend shows the paused run as Failed while the engine is still paused. ``` Before: Confirm Change on Python Lambda while paused -> exception escapes -> canvas shows Failed, Kill disabled; engine still PAUSED After: Confirm Change on Python Lambda while paused -> ModifyLogicResponse(isValid = false, "operator ... does not support reconfiguration") -> error notification, run stays paused, Resume works ``` | Before: after "Confirm Change", run shown as Failed | Before: the error, visible only with no operator selected | After: error notification, run still paused | | --- | --- | --- | | <img width="1263" height="799" alt="02-after-confirm-change-run-shown-failed" src="https://github.com/user-attachments/assets/80ae2fe1-60d8-4c98-9c45-a4f063bc2c3f" /> | <img width="1263" height="799" alt="04-static-error-compilation-error-unsupported-reconfiguration" src="https://github.com/user-attachments/assets/964bd200-1e98-424e-9fd3-9c67e1a4139f" /> | <img width="1263" height="799" alt="07-after-fix-error-notification-run-stays-paused" src="https://github.com/user-attachments/assets/31488856-e2e1-4ae5-8e82-f5ce11ba2332" /> | **Changes.** 1. `modifyOperatorLogic` wraps the `runtimeReconfiguration` call in `Try(...).flatten`, so a thrown exception takes the same rejected-edit path as a returned `Failure`: nothing is queued and the run stays paused. This also covers an override that throws while rebuilding its executor. `Try` catches `NonFatal` only. When the exception has no message, the response carries its string form instead of null. 2. No operator flag changes. The three operators above still offer "Unlock for Logic Change"; whether they should stop advertising `supportReconfiguration` or get a real override is left out of this PR. ### Any related issues, documentation, discussions? Closes #8967 ### How was this PR tested? Four new tests in `ExecutionReconfigurationServiceSpec`, each failing without the change it covers: a real `DummyOpDesc` whose base implementation throws; a test-only override that throws; a message-less exception reported by its type; an `InterruptedException` that still escapes. The three rejection tests also expect the pending queue untouched. ``` sbt "WorkflowExecutionService/testOnly org.apache.texera.web.service.ExecutionReconfigurationServiceSpec" # Tests: succeeded 22, failed 0 sbt "WorkflowOperator/testOnly org.apache.texera.amber.operator.filter.FilterOpDescSpec org.apache.texera.amber.operator.map.MapOpDescSpec" # 12 tests, 0 failures (the "propagate exceptions from getPhysicalOp" tests still pass) sbt "WorkflowExecutionService/scalafmtCheck" "WorkflowExecutionService/Test/scalafmtCheck" # clean ``` Mutation check: removing the `Try(...).flatten` wrap fails three of the new tests; replacing the message fallback with a bare `exception.getMessage` fails the no-message test. Manual check in Chrome on the local stack: Text Input -> Python UDF yielding once per second -> Python Lambda; Run, Pause, unlock the Python Lambda, change its expression, Confirm Change. On main the run is shown as Failed; on this branch an error notification appears, the button still reads "Resume", `workflow_executions` stays at PAUSED, and Resume continues the same execution. ### Was this PR authored or co-authored using generative AI tooling? Yes. Generated-by: Claude Code (claude-fable-5-1). Co-authored with Claude; the author reviewed the change before submission. --- .../service/ExecutionReconfigurationService.scala | 21 ++-- .../ExecutionReconfigurationServiceSpec.scala | 125 ++++++++++++++++++--- 2 files changed, 121 insertions(+), 25 deletions(-) diff --git a/amber/src/main/scala/org/apache/texera/web/service/ExecutionReconfigurationService.scala b/amber/src/main/scala/org/apache/texera/web/service/ExecutionReconfigurationService.scala index e4093ce4a7..56b75d1328 100644 --- a/amber/src/main/scala/org/apache/texera/web/service/ExecutionReconfigurationService.scala +++ b/amber/src/main/scala/org/apache/texera/web/service/ExecutionReconfigurationService.scala @@ -41,7 +41,7 @@ import org.apache.texera.web.model.websocket.response.{ import org.apache.texera.web.storage.{ExecutionReconfigurationStore, ExecutionStateStore} import java.util.UUID -import scala.util.{Failure, Success} +import scala.util.{Failure, Success, Try} class ExecutionReconfigurationService( client: AmberClient, @@ -72,16 +72,21 @@ class ExecutionReconfigurationService( "changed while the workflow runs." ) } else { + // An operator that throws instead of returning Failure, such as one without a + // runtimeReconfiguration override, is reported as a rejected edit the same way. val reconfiguredPhysicalOp = - currentOp.runtimeReconfiguration( - workflow.context.workflowId, - workflow.context.executionId, - currentOp, - newOp - ) + Try( + currentOp.runtimeReconfiguration( + workflow.context.workflowId, + workflow.context.executionId, + currentOp, + newOp + ) + ).flatten reconfiguredPhysicalOp match { case Failure(exception) => - ModifyLogicResponse(opId.id, isValid = false, exception.getMessage) + val reason = Option(exception.getMessage).getOrElse(exception.toString) + ModifyLogicResponse(opId.id, isValid = false, reason) case Success(op) => { stateStore.reconfigurationStore.updateState(old => old.copy(unscheduledReconfigurations = old.unscheduledReconfigurations :+ op) diff --git a/amber/src/test/scala/org/apache/texera/web/service/ExecutionReconfigurationServiceSpec.scala b/amber/src/test/scala/org/apache/texera/web/service/ExecutionReconfigurationServiceSpec.scala index 654168186d..cfde74887b 100644 --- a/amber/src/test/scala/org/apache/texera/web/service/ExecutionReconfigurationServiceSpec.scala +++ b/amber/src/test/scala/org/apache/texera/web/service/ExecutionReconfigurationServiceSpec.scala @@ -49,6 +49,7 @@ import org.apache.texera.amber.engine.architecture.rpc.controlcommands.WorkflowR import org.apache.texera.amber.engine.architecture.rpc.controlreturns.EmptyReturn import org.apache.texera.amber.engine.architecture.rpc.coordinatorservice.CoordinatorServiceFs2Grpc import org.apache.texera.amber.engine.common.client.AmberClient +import org.apache.texera.amber.operator.dummy.DummyOpDesc import org.apache.texera.amber.operator.filter.{ ComparisonType, FilterPredicate, @@ -156,12 +157,14 @@ class ExecutionReconfigurationServiceSpec op } + /** The message the test-only descriptor below throws from a reconfiguration with. */ + private val thrownMessage = "this operator blew up while being reconfigured" + /** - * No production descriptor ever returns `Failure` from `runtimeReconfiguration`: the six - * that override it all return `Success`, and the `LogicalOp` base throws - * `UnsupportedOperationException` instead. The failure arm therefore needs a test-only - * descriptor. It is invisible to `OperatorMetadataGenerator`, which resolves subtypes from - * the `@JsonSubTypes` annotation rather than by scanning the classpath. + * Returns `Failure` from `runtimeReconfiguration`. No production descriptor does: the six + * that override it all return `Success`, and the `LogicalOp` base throws instead. It is + * invisible to `OperatorMetadataGenerator`, which resolves subtypes from the `@JsonSubTypes` + * annotation rather than by scanning the classpath. */ private class RejectingReconfigurationOpDesc extends LogicalOp { override def operatorInfo: OperatorInfo = @@ -183,6 +186,29 @@ class ExecutionReconfigurationServiceSpec Failure(new RuntimeException(rejectionMessage)) } + /** Throws `failure()` from `runtimeReconfiguration`, the way an override that fails while + * rebuilding its executor does. + */ + private class ThrowingReconfigurationOpDesc(failure: () => Throwable) extends LogicalOp { + override def operatorInfo: OperatorInfo = + OperatorInfo( + "Throwing Reconfiguration", + "test-only operator whose runtime reconfiguration always throws", + OperatorGroupConstants.CLEANING_GROUP, + inputPorts = List(InputPort()), + outputPorts = List(OutputPort()), + supportReconfiguration = true + ) + + override def runtimeReconfiguration( + workflowId: WorkflowIdentity, + executionId: ExecutionIdentity, + oldOpDesc: LogicalOp, + newOpDesc: LogicalOp + ): Try[(PhysicalOp, Option[StateTransferFunc])] = + throw failure() + } + /** * Records the arguments `modifyOperatorLogic` hands to `runtimeReconfiguration`. Every * production override ignores the `oldOpDesc` parameter (FilterOpDesc, MapOpDesc, LimitOpDesc, @@ -446,35 +472,100 @@ class ExecutionReconfigurationServiceSpec deployedOp.seenExecutionId shouldBe testExecutionId } - it should "report the deployed operator's rejection and leave the pending queue untouched" in { - // The request carries a LimitOpDesc, which would reconfigure happily. Only the operator - // that is actually deployed refuses, so an invalid response proves the service asked the - // plan's operator rather than the one the frontend sent. - val opId = "rejecting-op" - val deployedOp = new RejectingReconfigurationOpDesc - deployedOp.setOperatorId(opId) + /** Sends an edit to a deployed `deployedOp` with one reconfiguration already pending and + * returns the response together with the ids left in the pending queue. + */ + private def modifyWithOnePending( + deployedOp: LogicalOp, + request: LogicalOp + ): (TexeraWebSocketEvent, List[PhysicalOpIdentity]) = { val stateStore = new ExecutionStateStore val service = new WorkflowOnlyService(stateStore, mkWorkflow(List(deployedOp))) - // An edit the user already made earlier in the same pause. val alreadyQueued = mkPhysicalOp("already-queued") stateStore.reconfigurationStore.updateState(_ => ExecutionReconfigurationStore(unscheduledReconfigurations = List((alreadyQueued, None))) ) + val response = service.modifyOperatorLogic(ModifyLogicRequest(request)) + val queued = stateStore.reconfigurationStore.getState.unscheduledReconfigurations + (response, queued.map(_._1.id)) + } + + it should "report the deployed operator's rejection and leave the pending queue untouched" in { + // The request carries a LimitOpDesc, which would reconfigure happily. Only the operator + // that is actually deployed refuses, so an invalid response proves the service asked the + // plan's operator rather than the one the frontend sent. + val opId = "rejecting-op" + val deployedOp = new RejectingReconfigurationOpDesc + deployedOp.setOperatorId(opId) - val response = service.modifyOperatorLogic(ModifyLogicRequest(mkLimitOp(opId, 7))) + val (response, queued) = modifyWithOnePending(deployedOp, mkLimitOp(opId, 7)) response shouldBe a[ModifyLogicResponse] val rejected = response.asInstanceOf[ModifyLogicResponse] rejected.opId shouldBe opId rejected.isValid shouldBe false - // The frontend shows this string in the operator's error box, so it has to be the reason the + // The frontend shows this string in an error notification, so it has to be the reason the // operator gave -- not an empty string, which is also what the valid arm reports. rejected.errorMessage shouldBe rejectionMessage // A rejected edit neither queues itself nor discards work that was already pending. - val queued = stateStore.reconfigurationStore.getState.unscheduledReconfigurations - queued.map(_._1.id) shouldBe List(alreadyQueued.id) + queued shouldBe List(mkPhysicalOp("already-queued").id) + } + + it should "report an operator without a reconfiguration override as a rejected edit" in { + // DummyOpDesc advertises supportReconfiguration but inherits the LogicalOp base, which + // throws UnsupportedOperationException instead of returning Failure. + val opId = "dummy-op" + val deployedOp = new DummyOpDesc + deployedOp.setOperatorId(opId) + + val (response, queued) = modifyWithOnePending(deployedOp, mkLimitOp(opId, 7)) + + response shouldBe a[ModifyLogicResponse] + val rejected = response.asInstanceOf[ModifyLogicResponse] + rejected.opId shouldBe opId + rejected.isValid shouldBe false + rejected.errorMessage should include("DummyOpDesc does not support reconfiguration") + queued shouldBe List(mkPhysicalOp("already-queued").id) + } + + it should "report an operator whose reconfiguration override throws as a rejected edit" in { + val opId = "throwing-op" + val deployedOp = + new ThrowingReconfigurationOpDesc(() => new IllegalStateException(thrownMessage)) + deployedOp.setOperatorId(opId) + + val (response, queued) = modifyWithOnePending(deployedOp, mkLimitOp(opId, 7)) + + response shouldBe a[ModifyLogicResponse] + val rejected = response.asInstanceOf[ModifyLogicResponse] + rejected.opId shouldBe opId + rejected.isValid shouldBe false + rejected.errorMessage shouldBe thrownMessage + queued shouldBe List(mkPhysicalOp("already-queued").id) + } + + it should "describe a rejection by its exception type when the exception has no message" in { + val opId = "throwing-op" + val deployedOp = new ThrowingReconfigurationOpDesc(() => new IllegalStateException()) + deployedOp.setOperatorId(opId) + + val (response, queued) = modifyWithOnePending(deployedOp, mkLimitOp(opId, 7)) + + response shouldBe a[ModifyLogicResponse] + val rejected = response.asInstanceOf[ModifyLogicResponse] + rejected.isValid shouldBe false + rejected.errorMessage shouldBe "java.lang.IllegalStateException" + queued shouldBe List(mkPhysicalOp("already-queued").id) + } + + it should "let a fatal reconfiguration exception escape instead of reporting a rejection" in { + val opId = "throwing-op" + val deployedOp = new ThrowingReconfigurationOpDesc(() => new InterruptedException("stop")) + deployedOp.setOperatorId(opId) + + an[InterruptedException] should be thrownBy modifyWithOnePending(deployedOp, mkLimitOp(opId, 7)) } // ---------------------------------------------------------------------------
