apache/dolphinscheduler · error · ServiceException

PROJECT_NOT_FOUND

PROJECT_NOT_FOUND

Error message

PROJECT_NOT_FOUND

What it means

Thrown by checkHasProjectWritePermissionThrowException when the Project argument is null. Distinct from PROJECT_NOT_EXIST: this is the write-permission check path signaling the project record could not be found.

Source

Thrown at dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ProjectServiceImpl.java:211

    @Override
    public void checkProjectAndAuthThrowException(User loginUser, Long projectCode, String permission) {
        if (projectCode == null) {
            throw new ServiceException(Status.PROJECT_NOT_EXIST);
        }
        Project project = projectDao.queryByCode(projectCode);
        checkProjectAndAuthThrowException(loginUser, project, permission);
    }

    @Override
    public void checkHasProjectWritePermissionThrowException(User loginUser, long projectCode) {
        Project project = projectDao.queryByCode(projectCode);
        checkHasProjectWritePermissionThrowException(loginUser, project);
    }

    @Override
    public void checkHasProjectWritePermissionThrowException(User loginUser, Project project) {
        if (project == null) {
            throw new ServiceException(Status.PROJECT_NOT_FOUND, null);
        }
        // case 1: user is admin
        if (loginUser.getUserType() == UserType.ADMIN_USER) {
            return;
        }
        // case 2: user is project owner
        if (project.getUserId().equals(loginUser.getId())) {
            return;
        }
        // case 3: check user permission level
        ProjectUser projectUser = projectUserDao.queryProjectRelation(project.getId(), loginUser.getId());
        if (projectUser == null || projectUser.getPerm() != Constants.DEFAULT_ADMIN_PERMISSION) {
            throw new ServiceException(Status.USER_NO_WRITE_PROJECT_PERM, loginUser.getUserName(), project.getCode());
        }
    }

    /**
     * admin can view all projects

View on GitHub (pinned to 02eac45a1b)

Solutions

  1. Look up the project first and confirm it exists before requesting write-permission checks
  2. Correct the project code used by the client
  3. Recreate the missing project if it was deleted unintentionally

Example fix

// before
projectService.checkHasProjectWritePermissionThrowException(loginUser, project);
// after
Project project = projectDao.queryByCode(projectCode);
if (project == null) {
    putMsg(result, Status.PROJECT_NOT_FOUND, projectCode);
    return result;
}
projectService.checkHasProjectWritePermissionThrowException(loginUser, project);
Defensive patterns

Strategy: validation

Validate before calling

Project project = projectDao.queryByCode(projectCode);
if (project == null) { throw new EntityNotFoundException("project " + projectCode); }

Type guard

if (projectCode != null && projectDao.queryByCode(projectCode) != null) { /* safe */ }

Try / catch

try {
    service.checkHasProjectWritePermissionThrowException(loginUser, project);
} catch (ServiceException e) {
    if (e.getCode() == Status.PROJECT_NOT_FOUND) { return notFound(); }
    throw e;
}

Prevention

When it happens

Trigger: Calling checkHasProjectWritePermissionThrowException (or the code-based wrapper that resolved no project) with a null project because projectDao lookup returned nothing for the given code.

Common situations: Workflow/process-definition operations referencing a project deleted earlier; import/export scripts using wrong project code; tests constructing requests with fabricated codes.

Understand the failure class

Background: "Not found" and "does not exist" errors: why "Task not found", "No such folder", and "Can't find" fire when a lookup comes back empty — this error's family across 14 libraries.

Related errors


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