{"record":{"id":"bc8600e5dda91da3","repo":"apache/dolphinscheduler","slug":"query-task-instance-log-error","errorCode":"QUERY_TASK_INSTANCE_LOG_ERROR","errorMessage":"QUERY_TASK_INSTANCE_LOG_ERROR: TaskInstanceLogPath is empty, maybe the taskInstance doesn't be dispatched","messagePattern":"QUERY_TASK_INSTANCE_LOG_ERROR: TaskInstanceLogPath is empty, maybe the taskInstance doesn't be dispatched","errorType":"error_code","errorClass":"ServiceException","httpStatus":null,"severity":"error","filePath":"dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/LoggerServiceImpl.java","lineNumber":187,"sourceCode":"            throw new ServiceException(\"task instance does not exist in project\");\n        }\n        return getLogBytes(task);\n    }\n\n    /**\n     * query log\n     *\n     * @param taskInstance task instance\n     * @param skipLineNum  skip line number\n     * @param limit        limit\n     * @return log string data\n     */\n    private String queryLog(TaskInstance taskInstance, int skipLineNum, int limit) {\n        final String logPath = taskInstance.getLogPath();\n        log.info(\"Query task instance log, taskInstanceId:{}, taskInstanceName:{}, host: {}, logPath:{}\",\n                taskInstance.getId(), taskInstance.getName(), taskInstance.getHost(), logPath);\n        if (StringUtils.isBlank(logPath)) {\n            throw new ServiceException(Status.QUERY_TASK_INSTANCE_LOG_ERROR,\n                    \"TaskInstanceLogPath is empty, maybe the taskInstance doesn't be dispatched\");\n        }\n\n        StringBuilder sb = new StringBuilder();\n        if (skipLineNum == 0) {\n            String head = String.format(LOG_HEAD_FORMAT,\n                    logPath,\n                    taskInstance.getHost(),\n                    Constants.SYSTEM_LINE_SEPARATOR);\n            sb.append(head);\n        }\n\n        try {\n            String logContent = logClientDelegate.getPartLogString(taskInstance, skipLineNum, limit);\n            if (logContent != null) {\n                sb.append(logContent);\n            }\n            return sb.toString();","sourceCodeStart":169,"sourceCodeEnd":205,"githubUrl":"https://github.com/apache/dolphinscheduler/blob/02eac45a1b6676e639fcbfb4be2243de5771b05d/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/LoggerServiceImpl.java#L169-L205","documentation":"Thrown by LoggerServiceImpl.queryLog when the task instance's logPath is blank. The log path is assigned when a task is dispatched, so a blank path means the task never reached a worker and has no log file to read.","triggerScenarios":"Calling GET /log/detail (queryLog) with skipLineNum/limit for a task instance whose t_ds_task_instance.log_path column is empty - i.e. the task was created but never dispatched.","commonSituations":"Task stuck in submitted/queued state; master failure before dispatch; viewing logs immediately after task creation before dispatch completes; workflow killed before dispatch.","solutions":["Check the task instance's state and logPath; if the task never dispatched, look at master logs instead of worker logs.","Wait until the task is dispatched and has a logPath, then retry the log query.","If the task is a zombie/stuck record, kill/re-run the workflow instance to get a properly dispatched task.","Verify master and worker are healthy; dispatch failures leave logPath empty."],"exampleFix":"// before\nString log = loggerService.queryLog(loginUser, projectCode, taskInstId, 0, 10);\n// after\nTaskInstance task = taskInstanceDao.queryById(taskInstId);\nif (task != null && StringUtils.isNotBlank(task.getLogPath())) {\n    String log = loggerService.queryLog(loginUser, projectCode, taskInstId, 0, 10);\n}","handlingStrategy":"validation","validationCode":"TaskInstance task = taskInstanceDao.queryById(taskInstId);\nif (task == null || StringUtils.isBlank(task.getLogPath())) {\n    throw new IllegalStateException(\"task not dispatched yet, no log path: \" + taskInstId);\n}","typeGuard":"boolean hasLog(TaskInstance task) {\n    return task != null && StringUtils.isNotBlank(task.getLogPath());\n}","tryCatchPattern":"try {\n    String log = loggerService.queryLog(loginUser, projectCode, taskInstId, skip, limit);\n} catch (ServiceException e) {\n    // task not dispatched; poll again later\n}","preventionTips":["Only query logs for tasks in a running/finished (dispatched) state.","Poll task state before first log fetch.","Check master health if tasks remain undispatched."],"tags":["dolphinscheduler","task-log","not-dispatched"],"backgroundTag":"empty-required-field","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"}