apache/dolphinscheduler · error · ServiceException
USER_NOT_EXIST
USER_NOT_EXIST
Error message
USER_NOT_EXIST: user does not exist
What it means
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.
Source
Thrown at dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ResourcesServiceImpl.java:397
} catch (Exception e) {
throw new ServiceException(
"Download the resource file: " + downloadFileRequest.getFileAbsolutePath() + " failed", e);
} finally {
FileUtils.deleteFile(localTmpFileAbsolutePath);
}
}
@Override
public StorageEntity queryFileStatus(String userName, String fileAbsolutePath) {
return storageOperator.getStorageEntity(fileAbsolutePath);
}
@Override
public String queryResourceBaseDir(User loginUser, ResourceType type) {
User user = userDao.queryById(loginUser.getId());
if (user == null) {
throw new ServiceException(Status.USER_NOT_EXIST);
}
Tenant tenant = tenantDao.queryOptionalById(user.getTenantId())
.orElseThrow(() -> new ServiceException(Status.CURRENT_LOGIN_USER_TENANT_NOT_EXIST));
return storageOperator.getStorageBaseDirectory(tenant.getTenantCode(), type);
}
// Copy the file to the local file system and return the local file absolute path
@SneakyThrows
private String copyFileToLocal(MultipartFile multipartFile) {
String localTmpFileAbsolutePath = FileUtils.getUploadFileLocalTmpAbsolutePath();
FileUtils.copyInputStreamToFile(multipartFile.getInputStream(), localTmpFileAbsolutePath);
return localTmpFileAbsolutePath;
}
// Copy the file to the local file system and return the local file absolute path
private String copyFileToLocal(String fileContent) {
String localTmpFileAbsolutePath = FileUtils.getUploadFileLocalTmpAbsolutePath();View on GitHub (pinned to 02eac45a1b)
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.
Example fix
// before: token of deleted user GET /resources/type/HDFS/dir -> USER_NOT_EXIST // after: re-authenticate POST /login (valid account) -> new sessionId -> GET /resources/... succeeds
Defensive patterns
Strategy: try-catch
Validate before calling
// verify the user still exists before calling
if (userDao.queryById(loginUser.getId()) == null) {
throw new IllegalStateException("Session user no longer exists; re-login required");
} Type guard
boolean userExists(User loginUser) { return loginUser != null && userDao.queryById(loginUser.getId()) != null; } Try / catch
try {
resourcesService.queryResourceBaseDir(loginUser, type);
} catch (ServiceException e) {
if (Status.USER_NOT_EXIST.getCode() == e.getCode()) {
// force re-authentication flow
} else { throw e; }
} Prevention
- Invalidate sessions when deleting users
- Avoid long-lived tokens for accounts that may be removed
- Re-authenticate on USER_NOT_EXIST instead of retrying
When it happens
Trigger: 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.
Common situations: 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.
Understand the failure class
Background: "User not found", "Invalid user", and "does not exist": what missing-user lookup errors mean across Rocket.Chat, LiteLLM, Phabricator, rustfs, and pnpm — this error's family across 10 libraries.
Related errors
- Update the resource file from content: {fileAbsolutePath} fa
- Download the resource file: {fileAbsolutePath} failed
- file extension cannot not change
AI-assisted analysis of apache/dolphinscheduler@02eac45a1b (2026-09-06).
Data as JSON: /api/errors/2fac0b91e85646a1.
Report an issue: GitHub.