{"record":{"id":"eb83911cbae42bd8","repo":"apache/dolphinscheduler","slug":"sagemaker-applicationid-is-null","errorCode":null,"errorMessage":"sagemaker applicationID is null","messagePattern":"sagemaker applicationID is null","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":155,"sourceCode":"\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            }\n        }\n        if (pipelineId == null) {\n            throw new TaskException(\"sagemaker applicationID is null\");\n        }\n    }\n\n    public StartPipelineExecutionRequest createStartPipelineRequest() throws SagemakerTaskException {\n\n        String requestJson = parameters.getSagemakerRequestJson();\n        requestJson = parseRequstJson(requestJson);\n\n        StartPipelineExecutionRequest startPipelineRequest;\n        try {\n            startPipelineRequest = objectMapper.readValue(requestJson, StartPipelineExecutionRequest.class);\n        } catch (Exception e) {\n            log.error(\"can not parse SagemakerRequestJson from json: {}\", requestJson);\n            throw new SagemakerTaskException(\"can not parse SagemakerRequestJson \", e);\n        }\n\n        log.info(\"Sagemaker task create StartPipelineRequest: {}\", startPipelineRequest);\n        return startPipelineRequest;","sourceCodeStart":137,"sourceCodeEnd":173,"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#L137-L173","documentation":"initPipelineId() lazily deserializes the stored appId JSON into a PipelineId; if it is still null it throws TaskException(\"sagemaker applicationID is null\"). It means cancelApplication or trackApplicationStatus ran before submitApplication ever recorded a SageMaker pipeline id.","triggerScenarios":"cancelApplication() or trackApplicationStatus() is invoked while getAppIds() is empty — e.g. task killed during init/submit before setAppIds() ran, or the stored appId JSON failed to parse back into PipelineUtils.PipelineId.","commonSituations":"User kills a SageMaker task milliseconds after launch, worker crash/restart wiped the in-memory pipelineId before the appId was persisted, or getAppIds() contains malformed JSON so parseObject returns null.","solutions":["Check whether setAppIds() was reached during submitApplication; if the task was killed mid-submit there is genuinely no pipeline to stop — treat as a no-op.","Log/examine the stored appId value; if it is malformed JSON fix whatever corrupted the appIds string.","Retry status tracking after submit completes so the pipeline id is available.","If caused by worker restart, re-run the task rather than cancelling."],"exampleFix":"// before\ncancelApplication() // throws when submitted-appIds never set\n// after\nif (StringUtils.isEmpty(getAppIds())) {\n    log.warn(\"sagemaker applicationID not set; nothing to cancel\");\n    return;\n}","handlingStrategy":"type-guard","validationCode":"if (StringUtils.isEmpty(task.getAppIds())) {\n    log.warn(\"No SageMaker pipeline id recorded; skip cancel/track\");\n    return;\n}","typeGuard":"PipelineId pid = StringUtils.isNotEmpty(getAppIds())\n        ? JSONUtils.parseObject(getAppIds(), PipelineUtils.PipelineId.class)\n        : null;\nif (pid == null) {\n    // handle absence instead of proceeding\n}","tryCatchPattern":"try {\n    task.trackApplicationStatus();\n} catch (TaskException e) {\n    if (e.getMessage().contains(\"applicationID is null\")) {\n        log.warn(\"Submit never completed; treating task as not started\");\n    } else throw e;\n}","preventionTips":["Only cancel/track tasks after submitApplication succeeded","Persist appIds promptly after submit to survive worker restarts","Log the appId value whenever set for debugging"],"tags":["sagemaker","state","lifecycle"],"backgroundTag":"missing-required-argument","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"}