{"record":{"id":"c071795444ab8582","repo":"apache/dolphinscheduler","slug":"linkis-task-id-is-null","errorCode":null,"errorMessage":"linkis task id is null","messagePattern":"linkis task id is null","errorType":"exception","errorClass":"TaskException","httpStatus":null,"severity":"error","filePath":"dolphinscheduler-task-plugin/dolphinscheduler-task-linkis/src/main/java/org/apache/dolphinscheduler/plugin/task/linkis/LinkisTask.java","lineNumber":203,"sourceCode":"        log.info(\"raw param config content : {}\", linkisParameters.getParamScript());\n        String script = \"\";\n        List<LinkisParameters.Param> paramList = linkisParameters.getParamScript();\n        for (LinkisParameters.Param param : paramList) {\n            script = script.concat(param.getProps())\n                    .concat(Constants.SPACE)\n                    .concat(param.getValue());\n        }\n        return script;\n    }\n\n    private void initTaskId() {\n        if (taskId == null) {\n            if (StringUtils.isNotEmpty(getAppIds())) {\n                taskId = getAppIds();\n            }\n        }\n        if (taskId == null) {\n            throw new TaskException(\"linkis task id is null\");\n        }\n    }\n\n    protected String findTaskId(String line) {\n        Matcher matcher = LINKIS_TASK_ID_REGEX.matcher(line);\n        if (matcher.find()) {\n            String str = matcher.group();\n            return str.substring(11);\n        }\n        return null;\n    }\n\n    protected String findStatus(String line) {\n        Matcher matcher = LINKIS_STATUS_REGEX.matcher(line);\n        if (matcher.find()) {\n            String str = matcher.group();\n            return str.substring(11);\n        }","sourceCodeStart":185,"sourceCodeEnd":221,"githubUrl":"https://github.com/apache/dolphinscheduler/blob/02eac45a1b6676e639fcbfb4be2243de5771b05d/dolphinscheduler-task-plugin/dolphinscheduler-task-linkis/src/main/java/org/apache/dolphinscheduler/plugin/task/linkis/LinkisTask.java#L185-L221","documentation":"LinkisTask.initTaskId() resolves the Linkis job id from the cached taskId field or getAppIds(). If both are null it throws TaskException('linkis task id is null') because status tracking and cancellation require the job id.","triggerScenarios":"trackApplicationStatus() or cancelApplication() runs before the job id was captured: submitApplication never ran or failed, the id regex never matched the output, and getAppIds() returned empty.","commonSituations":"Killing a task whose submission never wrote an appId; submit failed earlier; log parsing missed the id line; worker restart lost in-memory state.","solutions":["Ensure submitApplication() completed successfully and the Linkis output contained the task id.","Check that LINKIS_TASK_ID_REGEX still matches your Linkis CLI output format.","If the job exists, recover the appId (task instance records) or kill it from the Linkis console.","Rerun the workflow so a fresh submission produces a new id."],"exampleFix":null,"handlingStrategy":"validation","validationCode":"if (task.getAppIds() == null || task.getAppIds().isEmpty()) {\n    throw new IllegalStateException(\"Cannot track/cancel: Linkis job has no appId (was it submitted?)\");\n}","typeGuard":null,"tryCatchPattern":"try {\n    task.cancelApplication();\n} catch (TaskException e) {\n    if (e.getMessage().contains(\"linkis task id is null\")) {\n        // kill from Linkis console instead\n    }\n}","preventionTips":["Only track/cancel tasks after successful submitApplication().","Verify the task-id regex captures output on your Linkis version.","Persist appIds so state survives worker restarts."],"tags":["linkis","task-id","state","cancel"],"backgroundTag":"resource-not-found","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"}