apache/dolphinscheduler · error · ServiceException

10018

10018

Error message

project {projectCode} not found 

What it means

Thrown by the private requireProjectPerm helper when projectDao.queryByCode(projectCode) returns null. Task group operations (create/update/list by project) are scoped to a project, and no project exists with the given code for non-admin callers. Reported as Status.PROJECT_NOT_FOUND (code 10018) with the projectCode substituted into the message.

Source

Thrown at dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/TaskGroupServiceImpl.java:283

        List<TaskGroup> taskGroups = taskGroupMapper.selectByProjectCode(projectCode);
        if (CollectionUtils.isEmpty(taskGroups)) {
            return;
        }
        List<Integer> taskGroupIds = taskGroups.stream()
                .map(TaskGroup::getId)
                .collect(Collectors.toList());
        taskGroupQueueService.deleteByTaskGroupIds(taskGroupIds);
        taskGroupMapper.deleteBatchIds(taskGroupIds);
    }

    private void requireProjectPerm(User loginUser, long projectCode, boolean writePermission) {
        if (loginUser.getUserType() == UserType.ADMIN_USER) {
            return;
        }
        Project project = projectDao.queryByCode(projectCode);
        if (project == null) {
            log.warn("Project does not exist, projectCode:{}.", projectCode);
            throw new ServiceException(Status.PROJECT_NOT_FOUND, projectCode);
        }
        if (project.getUserId().equals(loginUser.getId())) {
            return;
        }
        ProjectUser projectUser = projectUserDao.queryProjectRelation(project.getId(), loginUser.getId());
        if (projectUser == null) {
            log.warn("User {} does not have operation permission for project {}", loginUser.getUserName(),
                    project.getCode());
            throw new ServiceException(Status.USER_NO_OPERATION_PROJECT_PERM, loginUser.getUserName(),
                    project.getCode());
        }
        if (writePermission && projectUser.getPerm() != Constants.DEFAULT_ADMIN_PERMISSION) {
            log.warn("User {} does not have write permission for project {}", loginUser.getUserName(),
                    project.getCode());
            throw new ServiceException(Status.USER_NO_WRITE_PROJECT_PERM, loginUser.getUserName(),
                    project.getCode());
        }
    }

View on GitHub (pinned to 02eac45a1b)

Solutions

  1. Look up the correct project code via GET /project/list (or the UI URL of the project).
  2. Confirm the project exists: SELECT * FROM t_ds_project WHERE code=<code>.
  3. Create the project first if it genuinely does not exist.
  4. Fix scripts that pass project name/id where the numeric project code is required.
  5. Use an admin account only to bypass the permission check, not the existence check — the lookup still fails if the code is wrong.

Example fix

// before
String projectCode = "data-pipeline"; // name, not code
taskGroupService.createTaskGroup(loginUser, name, desc, total, projectCode);
// after
Project project = projectDao.queryByCode(actualNumericCode);
if (project == null) {
    throw new IllegalArgumentException("project not found for code " + actualNumericCode);
}
taskGroupService.createTaskGroup(loginUser, name, desc, total, actualNumericCode);
Defensive patterns

Strategy: validation

Validate before calling

// Java: resolve and verify the project code before task group calls
Project project = projectDao.queryByCode(projectCode);
if (project == null) {
    throw new ServiceException(Status.PROJECT_NOT_FOUND, projectCode);
}

Type guard

boolean projectExists(long projectCode) {
    return projectDao.queryByCode(projectCode) != null;
}

Try / catch

try {
    taskGroupService.createTaskGroup(loginUser, name, desc, total, projectCode);
} catch (ServiceException e) {
    if (e.getCode() == 10018) {
        // refresh the project list; the code is stale or wrong
    }
    throw e;
}

Prevention

When it happens

Trigger: Calling createTaskGroup, updateTaskGroup, or queryTaskGroupByProjectCode with a projectCode that does not exist in t_ds_project; passing a project name instead of its code; using a code from a different environment's database.

Common situations: Hardcoded project codes from another install; project deleted while UI held the old code; confusing project code (long numeric) with project id; cross-environment API scripts.

Understand the failure class

Background: 'Could not be found', 'does not exist', 'not found in database': the resource-not-found family when an ID, slug, key, or URI lookup comes back empty — this error's family across 20 libraries.

Related errors


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