{"record":{"id":"2fac0b91e85646a1","repo":"apache/dolphinscheduler","slug":"user-not-exist","errorCode":"USER_NOT_EXIST","errorMessage":"USER_NOT_EXIST: user does not exist","messagePattern":"USER_NOT_EXIST: user does not exist","errorType":"error_code","errorClass":"ServiceException","httpStatus":null,"severity":"error","filePath":"dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ResourcesServiceImpl.java","lineNumber":397,"sourceCode":"        } catch (Exception e) {\n            throw new ServiceException(\n                    \"Download the resource file: \" + downloadFileRequest.getFileAbsolutePath() + \" failed\", e);\n        } finally {\n            FileUtils.deleteFile(localTmpFileAbsolutePath);\n        }\n    }\n\n    @Override\n    public StorageEntity queryFileStatus(String userName, String fileAbsolutePath) {\n        return storageOperator.getStorageEntity(fileAbsolutePath);\n    }\n\n    @Override\n    public String queryResourceBaseDir(User loginUser, ResourceType type) {\n\n        User user = userDao.queryById(loginUser.getId());\n        if (user == null) {\n            throw new ServiceException(Status.USER_NOT_EXIST);\n        }\n\n        Tenant tenant = tenantDao.queryOptionalById(user.getTenantId())\n                .orElseThrow(() -> new ServiceException(Status.CURRENT_LOGIN_USER_TENANT_NOT_EXIST));\n        return storageOperator.getStorageBaseDirectory(tenant.getTenantCode(), type);\n    }\n\n    // Copy the file to the local file system and return the local file absolute path\n    @SneakyThrows\n    private String copyFileToLocal(MultipartFile multipartFile) {\n        String localTmpFileAbsolutePath = FileUtils.getUploadFileLocalTmpAbsolutePath();\n        FileUtils.copyInputStreamToFile(multipartFile.getInputStream(), localTmpFileAbsolutePath);\n        return localTmpFileAbsolutePath;\n    }\n\n    // Copy the file to the local file system and return the local file absolute path\n    private String copyFileToLocal(String fileContent) {\n        String localTmpFileAbsolutePath = FileUtils.getUploadFileLocalTmpAbsolutePath();","sourceCodeStart":379,"sourceCodeEnd":415,"githubUrl":"https://github.com/apache/dolphinscheduler/blob/02eac45a1b6676e639fcbfb4be2243de5771b05d/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ResourcesServiceImpl.java#L379-L415","documentation":"ResourcesServiceImpl.queryResourceBaseDir throws ServiceException(Status.USER_NOT_EXIST) when userDao.queryById(loginUser.getId()) returns null — the authenticated user record is gone from the database even though a loginUser object was passed in. The method re-fetches the user to resolve their tenant before computing the storage base directory.","triggerScenarios":"Calling resource directory listing APIs with a loginUser whose id no longer exists (user deleted while session/token still valid); stale cached User object after admin removed the account; cross-environment token reuse.","commonSituations":"Admin deletes a user while their browser session is still active; automated scripts using tokens of removed service accounts; database restored/cleaned without invalidating old sessions.","solutions":["Re-login to obtain a fresh, valid session — the old user record no longer exists.","Recreate the missing user account if it was deleted accidentally, then retry.","Invalidate stale sessions/tokens after user deletion so callers fail fast with authentication errors instead."],"exampleFix":"// before: token of deleted user\nGET /resources/type/HDFS/dir -> USER_NOT_EXIST\n\n// after: re-authenticate\nPOST /login (valid account) -> new sessionId -> GET /resources/... succeeds","handlingStrategy":"try-catch","validationCode":"// verify the user still exists before calling\nif (userDao.queryById(loginUser.getId()) == null) {\n    throw new IllegalStateException(\"Session user no longer exists; re-login required\");\n}","typeGuard":"boolean userExists(User loginUser) { return loginUser != null && userDao.queryById(loginUser.getId()) != null; }","tryCatchPattern":"try {\n    resourcesService.queryResourceBaseDir(loginUser, type);\n} catch (ServiceException e) {\n    if (Status.USER_NOT_EXIST.getCode() == e.getCode()) {\n        // force re-authentication flow\n    } else { throw e; }\n}","preventionTips":["Invalidate sessions when deleting users","Avoid long-lived tokens for accounts that may be removed","Re-authenticate on USER_NOT_EXIST instead of retrying"],"tags":["resources","user","stale-session"],"backgroundTag":"user-not-found","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"}