{"record":{"id":"8485a14e75a1cf4c","repo":"apache/dolphinscheduler","slug":"cancel-application-error-8485a1","errorCode":null,"errorMessage":"cancel application error","messagePattern":"cancel application error","errorType":"exception","errorClass":"TaskException","httpStatus":null,"severity":"error","filePath":"dolphinscheduler-task-plugin/dolphinscheduler-task-sagemaker/src/main/java/org/apache/dolphinscheduler/plugin/task/sagemaker/SagemakerTask.java","lineNumber":134,"sourceCode":"            // Start pipeline\n            pipelineId = utils.startPipelineExecution(client, request);\n\n            // set AppId\n            setAppIds(JSONUtils.toJsonString(pipelineId));\n        } catch (Exception e) {\n            setExitStatusCode(TaskConstants.EXIT_CODE_FAILURE);\n            throw new TaskException(\"SageMaker task submit error\", e);\n        }\n    }\n\n    @Override\n    public void cancelApplication() {\n        initPipelineId();\n        try {\n            // stop pipeline\n            utils.stopPipelineExecution(client, pipelineId);\n        } catch (Exception e) {\n            throw new TaskException(\"cancel application error\", e);\n        }\n    }\n\n    @Override\n    public void trackApplicationStatus() throws TaskException {\n        initPipelineId();\n        // Keep checking the health status\n        exitStatusCode = utils.checkPipelineExecutionStatus(client, pipelineId);\n    }\n\n    /**\n     * init sagemaker applicationId if null\n     */\n    private void initPipelineId() {\n        if (pipelineId == null) {\n            if (StringUtils.isNotEmpty(getAppIds())) {\n                pipelineId = JSONUtils.parseObject(getAppIds(), PipelineUtils.PipelineId.class);\n            }","sourceCodeStart":116,"sourceCodeEnd":152,"githubUrl":"https://github.com/apache/dolphinscheduler/blob/02eac45a1b6676e639fcbfb4be2243de5771b05d/dolphinscheduler-task-plugin/dolphinscheduler-task-sagemaker/src/main/java/org/apache/dolphinscheduler/plugin/task/sagemaker/SagemakerTask.java#L116-L152","documentation":"SagemakerTask.cancelApplication() resolves the stored pipeline id and calls utils.stopPipelineExecution(); any exception is rethrown as TaskException(\"cancel application error\", e). It means the AWS StopPipelineExecution call failed when the user tried to kill the running SageMaker task.","triggerScenarios":"utils.stopPipelineExecution(client, pipelineId) throws: pipeline already in a terminal state (cannot be stopped), insufficient IAM permissions, wrong region/credentials, or transient SDK/network errors.","commonSituations":"Killing a task whose pipeline already SUCCEEDED/FAILED (AWS refuses StopPipelineExecution on finished executions), IAM user lacking sagemaker:StopPipelineExecution, credentials rotated between submit and cancel.","solutions":["Inspect the cause chain: 'cannot be stopped' style AWS errors mean the pipeline already finished — the kill is harmless, verify final status instead.","Grant sagemaker:StopPipelineExecution to the configured IAM identity.","Verify AWS region/credentials on the datasource are still valid.","Retry the kill; transient SDK failures may clear on a second attempt."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try {\n    task.cancelApplication();\n} catch (TaskException e) {\n    Throwable cause = e.getCause();\n    if (cause != null && cause.getMessage().contains(\"cannot be stopped\")) {\n        log.info(\"Pipeline already finished; ignoring cancel failure\");\n    } else {\n        throw e;\n    }\n}","preventionTips":["Grant sagemaker:StopPipelineExecution to the configured IAM identity","Expect terminal-state pipelines to be un-stoppable and handle gracefully","Keep datasource credentials valid for the task's whole lifetime"],"tags":["sagemaker","aws","cancel"],"backgroundTag":"api-request-failed","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"}