{"record":{"id":"4788aab253ae72ff","repo":"apache/dolphinscheduler","slug":"cancel-emr-step-failed-message-cancelemrstepinf","errorCode":null,"errorMessage":"cancel emr step failed, message:${cancelEmrStepInfo.getReason()}","messagePattern":"cancel emr step failed, message:(.+?)","errorType":"exception","errorClass":"EmrTaskException","httpStatus":null,"severity":"error","filePath":"dolphinscheduler-task-plugin/dolphinscheduler-task-emr/src/main/java/org/apache/dolphinscheduler/plugin/task/emr/EmrAddStepsTask.java","lineNumber":206,"sourceCode":"    @Override\n    public void cancelApplication() throws TaskException {\n        log.info(\"trying cancel emr step, taskId:{}, clusterId:{}, stepId:{}\",\n                this.taskExecutionContext.getTaskInstanceId(), clusterId, stepId);\n        CancelStepsRequest cancelStepsRequest = new CancelStepsRequest().withClusterId(clusterId).withStepIds(stepId);\n        CancelStepsResult cancelStepsResult = emrClient.cancelSteps(cancelStepsRequest);\n\n        if (cancelStepsResult == null) {\n            throw new EmrTaskException(\"cancel emr step failed\");\n        }\n\n        CancelStepsInfo cancelEmrStepInfo = cancelStepsResult.getCancelStepsInfoList()\n                .stream()\n                .filter(cancelStepsInfo -> cancelStepsInfo.getStepId().equals(stepId))\n                .findFirst()\n                .orElseThrow(() -> new EmrTaskException(\"cancel emr step failed\"));\n\n        if (CancelStepsRequestStatus.FAILED.toString().equals(cancelEmrStepInfo.getStatus())) {\n            throw new EmrTaskException(\"cancel emr step failed, message:\" + cancelEmrStepInfo.getReason());\n        }\n\n        log.info(\"the result of cancel emr step is:{}\", cancelStepsResult);\n    }\n\n}\n","sourceCodeStart":188,"sourceCodeEnd":213,"githubUrl":"https://github.com/apache/dolphinscheduler/blob/02eac45a1b6676e639fcbfb4be2243de5771b05d/dolphinscheduler-task-plugin/dolphinscheduler-task-emr/src/main/java/org/apache/dolphinscheduler/plugin/task/emr/EmrAddStepsTask.java#L188-L213","documentation":"Semantic guard in cancelApplication: the CancelStepsResult was returned, but its embedded CancelStepsInfo reports the cancellation was NOT accepted — AWS rejected the cancel (e.g. the step is already in a terminal state) with a reason string interpolated into the message. The offending input is the AWS-returned cancelEmrStepInfo reason.","triggerScenarios":"Thrown at dolphinscheduler-task-plugin/dolphinscheduler-task-emr/src/main/java/org/apache/dolphinscheduler/plugin/task/emr/EmrAddStepsTask.java:206 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Read the interpolated reason — typically the step already completed/failed/cancelled, in which case no action is needed","Track the step's terminal status instead of re-issuing cancel when the step is already terminal"],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"02eac45a1b6676e639fcbfb4be2243de5771b05d","analyzedAt":"2026-09-06T17:43:00.555Z","contentChangedAt":"2026-09-06T17:43:00.555Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}