apache/dolphinscheduler · error · ServiceException

QUERY_TASK_INSTANCE_LOG_ERROR

QUERY_TASK_INSTANCE_LOG_ERROR

Error message

QUERY_TASK_INSTANCE_LOG_ERROR: TaskInstanceLogPath is empty, maybe the taskInstance doesn't be dispatched

What it means

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.

Source

Thrown at dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/LoggerServiceImpl.java:187

            throw new ServiceException("task instance does not exist in project");
        }
        return getLogBytes(task);
    }

    /**
     * query log
     *
     * @param taskInstance task instance
     * @param skipLineNum  skip line number
     * @param limit        limit
     * @return log string data
     */
    private String queryLog(TaskInstance taskInstance, int skipLineNum, int limit) {
        final String logPath = taskInstance.getLogPath();
        log.info("Query task instance log, taskInstanceId:{}, taskInstanceName:{}, host: {}, logPath:{}",
                taskInstance.getId(), taskInstance.getName(), taskInstance.getHost(), logPath);
        if (StringUtils.isBlank(logPath)) {
            throw new ServiceException(Status.QUERY_TASK_INSTANCE_LOG_ERROR,
                    "TaskInstanceLogPath is empty, maybe the taskInstance doesn't be dispatched");
        }

        StringBuilder sb = new StringBuilder();
        if (skipLineNum == 0) {
            String head = String.format(LOG_HEAD_FORMAT,
                    logPath,
                    taskInstance.getHost(),
                    Constants.SYSTEM_LINE_SEPARATOR);
            sb.append(head);
        }

        try {
            String logContent = logClientDelegate.getPartLogString(taskInstance, skipLineNum, limit);
            if (logContent != null) {
                sb.append(logContent);
            }
            return sb.toString();

View on GitHub (pinned to 02eac45a1b)

Solutions

  1. Check the task instance's state and logPath; if the task never dispatched, look at master logs instead of worker logs.
  2. Wait until the task is dispatched and has a logPath, then retry the log query.
  3. If the task is a zombie/stuck record, kill/re-run the workflow instance to get a properly dispatched task.
  4. Verify master and worker are healthy; dispatch failures leave logPath empty.

Example fix

// before
String log = loggerService.queryLog(loginUser, projectCode, taskInstId, 0, 10);
// after
TaskInstance task = taskInstanceDao.queryById(taskInstId);
if (task != null && StringUtils.isNotBlank(task.getLogPath())) {
    String log = loggerService.queryLog(loginUser, projectCode, taskInstId, 0, 10);
}
Defensive patterns

Strategy: validation

Validate before calling

TaskInstance task = taskInstanceDao.queryById(taskInstId);
if (task == null || StringUtils.isBlank(task.getLogPath())) {
    throw new IllegalStateException("task not dispatched yet, no log path: " + taskInstId);
}

Type guard

boolean hasLog(TaskInstance task) {
    return task != null && StringUtils.isNotBlank(task.getLogPath());
}

Try / catch

try {
    String log = loggerService.queryLog(loginUser, projectCode, taskInstId, skip, limit);
} catch (ServiceException e) {
    // task not dispatched; poll again later
}

Prevention

When it happens

Trigger: 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.

Common situations: Task stuck in submitted/queued state; master failure before dispatch; viewing logs immediately after task creation before dispatch completes; workflow killed before dispatch.

Understand the failure class

Background: "must not be empty", "cannot be empty" — required-field validation errors across open-source libraries — this error's family across 41 libraries.

Related errors


AI-assisted analysis of apache/dolphinscheduler@02eac45a1b (2026-09-06). Data as JSON: /api/errors/bc8600e5dda91da3. Report an issue: GitHub.