{"record":{"id":"ead9e7b01828aa60","repo":"apache/dolphinscheduler","slug":"the-workflow-workflowexecution-getname-i","errorCode":null,"errorMessage":"\"The workflow \" + workflowExecution.getName() + \"is failed, shouldn't emit workflow finished event\"","messagePattern":"\"The workflow \" \\+ workflowExecution\\.getName\\(\\) \\+ \"is failed, shouldn't emit workflow finished event\"","errorType":"exception","errorClass":"IllegalStateException","httpStatus":null,"severity":"error","filePath":"dolphinscheduler-master/src/main/java/org/apache/dolphinscheduler/server/master/engine/workflow/statemachine/WorkflowFailedStateAction.java","lineNumber":114,"sourceCode":"\n    @Override\n    public void onFinalizeEvent(final IWorkflowExecution workflowExecution,\n                                final WorkflowFinalizeLifecycleEvent workflowFinalizeEvent) {\n        throwExceptionIfStateIsNotMatch(workflowExecution);\n        super.finalizeEventAction(workflowExecution);\n    }\n\n    @Override\n    public WorkflowExecutionStatus matchState() {\n        return WorkflowExecutionStatus.FAILURE;\n    }\n\n    /**\n     * The running state can only finish with success/failure.\n     */\n    @Override\n    protected void emitWorkflowFinishedEventIfApplicable(IWorkflowExecution workflowExecution) {\n        throw new IllegalStateException(\n                \"The workflow \" + workflowExecution.getName() +\n                        \"is failed, shouldn't emit workflow finished event\");\n    }\n}\n","sourceCodeStart":96,"sourceCodeEnd":119,"githubUrl":"https://github.com/apache/dolphinscheduler/blob/02eac45a1b6676e639fcbfb4be2243de5771b05d/dolphinscheduler-master/src/main/java/org/apache/dolphinscheduler/server/master/engine/workflow/statemachine/WorkflowFailedStateAction.java#L96-L119","documentation":"WorkflowFailedStateAction forbids emitting a workflow finished event: a failed workflow should not additionally produce a 'finished' completion event. Hitting this throw means the state machine routed a finish event to the failed-state handler — an invariant violation.","triggerScenarios":"emitWorkflowFinishedEventIfApplicable called on a workflow execution whose state is FAILED, e.g. duplicate WorkflowFinishedEvent delivery or wrong event routing.","commonSituations":"Event bus replay after failover, double fire of workflow-finished events, bugs in event-to-state-action dispatch.","solutions":["Trace the source of the duplicate WorkflowFinishedEvent","Ensure events are de-duplicated/filtered by workflow execution id","Verify failover logic doesn't re-emit finish events for already-failed workflows","Upgrade to a version with idempotent event handling"],"exampleFix":"// before\nworkflowFinishedEventHandler.handle(event); // throws for FAILED workflows\n// after\nif (workflowExecution.getState() != WorkflowExecutionStatus.FAILURE) {\n    workflowFinishedEventHandler.handle(event);\n}","handlingStrategy":"validation","validationCode":"if (workflowExecution.getState() == WorkflowExecutionStatus.FAILURE) { log.warn(\"skip finished event for failed workflow\"); return; }","typeGuard":"boolean canEmitFinished(IWorkflowExecution w) { return w.getState() != WorkflowExecutionStatus.FAILURE; }","tryCatchPattern":"try { emitFinished(workflowExecution); } catch (IllegalStateException e) { log.warn(\"finished event rejected: {}\", e.getMessage()); }","preventionTips":["Emit workflow finished events only once per execution","Filter stale events for already-terminal workflows","Make finish-event handling idempotent"],"tags":["java","state-machine","workflow"],"backgroundTag":"invalid-state-transition","analyzedSha":"02eac45a1b6676e639fcbfb4be2243de5771b05d","analyzedAt":"2026-09-06T17:43:00.555Z","contentChangedAt":"2026-09-06T17:43:00.555Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}