apache/dolphinscheduler · error · ServiceException
1400001
1400001
Error message
The current user does not have this permission.
What it means
ServiceException(Status.NO_CURRENT_OPERATING_PERMISSION, code 1400001) is thrown in grantProjectWithReadPerm when the login user is not an administrator. Only admins may grant read permission on projects to other users; the isAdmin(loginUser) check fails before any lookup or grant happens. It is an authorization failure on the caller's identity, independent of the target user or projects.
Source
Thrown at dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/UsersServiceImpl.java:501
// 4. delete the relationship between project and user
this.projectUserDao.deleteProjectRelation(project.getId(), user.getId());
}
});
}
/**
* grant project with read permission
*
* @param loginUser login user
* @param userId user id
* @param projectIds project id array
* @return grant result code
*/
@Override
@Transactional(rollbackFor = RuntimeException.class)
public void grantProjectWithReadPerm(User loginUser, int userId, String projectIds) {
if (!isAdmin(loginUser)) {
throw new ServiceException(Status.NO_CURRENT_OPERATING_PERMISSION);
}
// check exist
User tempUser = userDao.queryById(userId);
if (tempUser == null) {
throw new ServiceException(Status.USER_NOT_EXIST, userId);
}
if (StringUtils.isEmpty(projectIds)) {
return;
}
Arrays.stream(projectIds.split(Constants.COMMA)).distinct().forEach(projectId -> {
ProjectUser projectUserOld = projectUserDao.queryProjectRelation(Integer.parseInt(projectId), userId);
if (projectUserOld != null) {
projectUserDao.deleteProjectRelation(Integer.parseInt(projectId), userId);
}
Date now = new Date();
ProjectUser projectUser = new ProjectUser();View on GitHub (pinned to 02eac45a1b)
Solutions
- Log in as (or use a token of) an admin user before calling this API.
- Grant the ADMIN_USER user type to the account in Users management if it legitimately needs this duty.
- Change the workflow so regular users request grants through an admin-approved path instead of calling the admin endpoint.
- Check the caller's role in your client code and fail fast with a clear message.
Example fix
// before
usersService.grantProjectWithReadPerm(currentUser, userId, projectIds); // throws if currentUser is not admin
// after
if (!LoginUserTypeChecker.isAdmin(currentUser)) {
throw new SecurityException("Admin privileges required to grant project read permission");
}
usersService.grantProjectWithReadPerm(currentUser, userId, projectIds); Defensive patterns
Strategy: validation
Validate before calling
if (loginUser == null || loginUser.getUserType() != UserType.ADMIN_USER) {
throw new SecurityException("grantProjectWithReadPerm requires an admin user");
} Type guard
boolean isAdminUser(User u) { return u != null && u.getUserType() == UserType.ADMIN_USER; } Try / catch
try {
usersService.grantProjectWithReadPerm(loginUser, userId, projectIds);
} catch (ServiceException e) {
if (e.getCode() == 1400001) { /* not admin: switch to admin credentials */ }
else throw e;
} Prevention
- Keep a dedicated admin service account for grant/revoke automation.
- Check userType before calling admin-only endpoints instead of discovering via 1400001.
- Detect token/role downgrades after re-authentication and refresh credentials.
When it happens
Trigger: Calling grantProjectWithReadPerm(loginUser, userId, projectIds) while loginUser has USER_TYPE.GENERAL_USER instead of ADMIN_USER.
Common situations: A regular user's session/token is used to call the admin-only grant REST endpoint; role downgraded after token issued; service account lacks admin role in a CI script.
Understand the failure class
Background: "You do not have permission" / 403 Forbidden errors: authenticated but not allowed — causes and fixes across open-source libraries — this error's family across 31 libraries.
Related errors
- user %s doesn't exist
- user %s doesn't have permission of %s %s
- 20016
- USER_NO_OPERATION_PERM
- USER_NO_OPERATION_PERM
AI-assisted analysis of apache/dolphinscheduler@02eac45a1b (2026-09-06).
Data as JSON: /api/errors/a4f1b1e022ea89f4.
Report an issue: GitHub.