[SPARK-57525][CONNECT] Declarative Pipelines should not throw NoSuchElementException when a run fails without an attached cause#56594
Open
LuciferYang wants to merge 1 commit into
Conversation
…lementException when a run fails without an attached cause
When a pipeline run fails, PipelinesHandler.startRun rethrows the failure to the Spark Connect client via runFailureEvent.foreach { event => throw event.error.get }. But event.error is None for some run termination reasons - UnexpectedRunFailure and FailureStoppingFlow both have cause = None - so event.error.get raised a NoSuchElementException, crashing the handler with a meaningless internal error and hiding the real failure (e.g. "Run failed unexpectedly.") from the client. These reasons reach this code via the asynchronous onCompletion path, where PipelineExecution.runPipeline's own catch never fires.
Extract the rethrow into throwRunFailure: when a cause is present it is rethrown unchanged; when absent, throw a SparkException with a new PIPELINE_RUN_FAILED error condition carrying the run's termination message. PIPELINE_RUN_FAILED (rather than INTERNAL_ERROR) is used so operational outcomes such as FailureStoppingFlow are not mislabeled as Spark bugs.
Added PipelinesHandlerSuite. The cause-less termination reasons cannot be triggered deterministically through the end-to-end run path, so the rethrow is unit-tested directly using the real UnexpectedRunFailure and FailureStoppingFlow messages.
5d686df to
c8e4062
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What changes were proposed in this pull request?
PipelinesHandler.startRunrethrows a failed pipeline run to the Spark Connect client viarunFailureEvent.foreach { event => throw event.error.get }. Butevent.errorisNonefor run termination reasons that carry no cause -UnexpectedRunFailureandFailureStoppingFlowboth havecause = None- soevent.error.getraised aNoSuchElementException, crashing the handler and hiding the real failure from the client.This PR extracts the rethrow into
throwRunFailure: when the failure has a cause it is rethrown unchanged; when it does not, aSparkExceptionwith a newPIPELINE_RUN_FAILEDerror condition is thrown, carrying the run's termination message.PIPELINE_RUN_FAILED(rather thanINTERNAL_ERROR) is used so that operational outcomes such asFailureStoppingFloware not mislabeled as Spark bugs.Why are the changes needed?
A run that fails without an attached cause (e.g.
UnexpectedRunFailure, or a flow that fails to stop) currently surfaces to the Connect client as an opaqueNoSuchElementException("None.get") instead of the actual run-failure message. That masks the real problem and looks like an internal error. These reasons reach this code via the asynchronousonCompletionpath, wherePipelineExecution.runPipeline's own catch never fires.Does this PR introduce any user-facing change?
Yes. When a pipeline run fails without an attached cause, the Spark Connect client now receives a
PIPELINE_RUN_FAILEDerror carrying the run's termination message (e.g. "Run failed unexpectedly.") instead of aNoSuchElementException.How was this patch tested?
New
PipelinesHandlerSuiteunit-teststhrowRunFailurefor both cases: the cause-present case rethrows the original cause, and the no-cause case throws aPIPELINE_RUN_FAILEDSparkExceptioncarrying the termination message (verified withcheckError, using the realUnexpectedRunFailureandFailureStoppingFlowmessages). The cause-less termination reasons cannot be triggered deterministically through the end-to-end run path, so the rethrow is unit-tested directly.SparkThrowableSuitevalidates the new error condition.Was this patch authored or co-authored using generative AI tooling?
Generated-by: Claude Code (Claude Opus 4.8)