{"record":{"id":"4df63c7ed3c1c3c8","repo":"apache/dolphinscheduler","slug":"project-not-exist","errorCode":"PROJECT_NOT_EXIST","errorMessage":"PROJECT_NOT_EXIST","messagePattern":"PROJECT_NOT_EXIST","errorType":"error_code","errorClass":"ServiceException","httpStatus":null,"severity":"error","filePath":"dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ProjectServiceImpl.java","lineNumber":185,"sourceCode":"        Project project = projectDao.queryByCode(projectCode);\n        checkProjectAndAuthThrowException(loginUser, project, PROJECT);\n        result.setData(project);\n        putMsg(result, Status.SUCCESS);\n        return result;\n    }\n\n    @Override\n    public Project queryByName(User loginUser, String projectName) {\n        Project project = projectDao.queryByName(projectName);\n        checkProjectAndAuthThrowException(loginUser, project, PROJECT);\n        return project;\n    }\n\n    @Override\n    public void checkProjectAndAuthThrowException(@NonNull User loginUser, @Nullable Project project,\n                                                  String permission) {\n        if (project == null) {\n            throw new ServiceException(Status.PROJECT_NOT_EXIST);\n        }\n        if (!canOperatorPermissions(loginUser, new Object[]{project.getId()}, AuthorizationType.PROJECTS, permission)) {\n            throw new ServiceException(Status.USER_NO_OPERATION_PROJECT_PERM, loginUser.getUserName(),\n                    project.getCode());\n        }\n    }\n\n    @Override\n    public void checkProjectAndAuthThrowException(User loginUser, Long projectCode, String permission) {\n        if (projectCode == null) {\n            throw new ServiceException(Status.PROJECT_NOT_EXIST);\n        }\n        Project project = projectDao.queryByCode(projectCode);\n        checkProjectAndAuthThrowException(loginUser, project, permission);\n    }\n\n    @Override\n    public void checkHasProjectWritePermissionThrowException(User loginUser, long projectCode) {","sourceCodeStart":167,"sourceCodeEnd":203,"githubUrl":"https://github.com/apache/dolphinscheduler/blob/02eac45a1b6676e639fcbfb4be2243de5771b05d/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ProjectServiceImpl.java#L167-L203","documentation":"Thrown by ProjectServiceImpl.checkProjectAndAuthThrowException when the Project lookup yields null, i.e. the requested project does not exist in the database. It is the project-existence gate used by queryByCode, queryByName, deleteProject and queryAuthorizedUser before any authorization check.","triggerScenarios":"Calling queryByCode/queryByName with a code/name that matches no project; calling the Long projectCode overload with projectCode=null; the project was deleted between obtaining the code and the call.","commonSituations":"Stale project codes cached in clients after a project was dropped; typos in project names; passing null projectCode from an unvalidated request parameter; multi-env setups pointing at the wrong database.","solutions":["Verify the project code/name exists (query the t_ds_project table or GET /projects list) before the call","Check the caller is not passing null projectCode; reject null/blank at the controller","Re-fetch the project code from the server rather than using a cached value"],"exampleFix":"// before\nprojectService.checkProjectAndAuthThrowException(loginUser, projectCode, Permissions.READ);\n// after\nProject project = projectDao.queryByCode(projectCode);\nif (project == null) {\n    putMsg(result, Status.PROJECT_NOT_EXIST);\n    return result;\n}\nprojectService.checkProjectAndAuthThrowException(loginUser, project, Permissions.READ);","handlingStrategy":"validation","validationCode":"Project project = projectDao.queryByCode(projectCode);\nif (project == null) { throw new ProjectNotFoundException(projectCode); }","typeGuard":"if (projectCode == null) return false;\nreturn projectDao.queryByCode(projectCode) != null;","tryCatchPattern":"try {\n    service.checkProjectAndAuthThrowException(loginUser, projectCode, perm);\n} catch (ServiceException e) {\n    if (e.getCode() == Status.PROJECT_NOT_EXIST) { /* render 'project not found' UI */ }\n    throw e;\n}","preventionTips":["Resolve project codes from the server list API instead of hardcoding","Null-check projectCode before service calls","Refresh cached project references after deletions"],"tags":["api","project","not-found"],"backgroundTag":"entity-not-found","analyzedSha":"02eac45a1b6676e639fcbfb4be2243de5771b05d","analyzedAt":"2026-09-06T17:43:00.555Z","contentChangedAt":"2026-09-06T17:43:00.555Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}