apache/dolphinscheduler · error · ServiceException
USER_NO_OPERATION_PERM
USER_NO_OPERATION_PERM
Error message
USER_NO_OPERATION_PERM
What it means
queryAccessTokenByUser enforces that a GENERAL_USER may only query their own access tokens; if loginUser.getUserType() is GENERAL_USER and loginUser.getId() != userId, it throws ServiceException(Status.USER_NO_OPERATION_PERM). Admin users bypass this check, and for admins the userId is normalized to 0 to return all tokens.
Source
Thrown at dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/AccessTokenServiceImpl.java:89
}
IPage<AccessToken> accessTokenList = accessTokenDao.queryAccessTokenPage(page, searchVal, userId);
pageInfo.setTotal((int) accessTokenList.getTotal());
pageInfo.setTotalList(accessTokenList.getRecords());
return pageInfo;
}
/**
* query access token for specified user
*
* @param loginUser login user
* @param userId user id
* @return token list for specified user
*/
@Override
public List<AccessToken> queryAccessTokenByUser(User loginUser, Integer userId) {
// no permission
if (loginUser.getUserType().equals(UserType.GENERAL_USER) && loginUser.getId() != userId) {
throw new ServiceException(Status.USER_NO_OPERATION_PERM);
}
userId = loginUser.getUserType().equals(UserType.ADMIN_USER) ? 0 : userId;
// query access token for specified user
List<AccessToken> accessTokenList = this.accessTokenDao.queryAccessTokenByUser(userId);
return accessTokenList;
}
/**
* create token
*
* @param loginUser loginUser
* @param userId token for user
* @param expireTime token expire time
* @param token token string (if it is absent, it will be automatically generated)
* @return create result code
*/
@SuppressWarnings("checkstyle:WhitespaceAround")
@OverrideView on GitHub (pinned to 02eac45a1b)
Solutions
- Query access tokens with your own userId, or authenticate as an ADMIN_USER when querying tokens on behalf of other users.
- Fix the calling client to pass the id of the currently logged-in user rather than a hard-coded or stale id.
- If cross-user visibility is required, have an administrator perform the query.
- Check UI/session handling so the correct current user id is sent after login switches.
Example fix
// before: general user querying another user's tokens accessTokenService.queryAccessTokenByUser(loginUser, otherUserId); // after: query own tokens, or use an admin account accessTokenService.queryAccessTokenByUser(loginUser, loginUser.getId());
Defensive patterns
Strategy: validation
Validate before calling
// client-side check before calling the API
if (loginUser.userType == GENERAL_USER && loginUser.id != targetUserId) {
throw new SecurityException("General users may only query their own access tokens");
} Type guard
boolean canQuery(User loginUser, Integer targetUserId) {
return loginUser != null && targetUserId != null
&& (loginUser.getUserType() == UserType.ADMIN_USER || loginUser.getId() == targetUserId.intValue());
} Try / catch
try {
return accessTokenService.queryAccessTokenByUser(loginUser, userId);
} catch (ServiceException e) {
if (e.getCode() == Status.USER_NO_OPERATION_PERM) {
return Collections.emptyList(); // or surface 403 to caller
}
throw e;
} Prevention
- Always pass the logged-in user's own id for non-admin callers.
- Fix UI state so stale user ids from previous sessions are not reused.
- Use admin credentials for cross-user token administration.
- Never enumerate other users' ids with a general-user token.
When it happens
Trigger: Calling the access-token query API (GET /users/{userId}/access-tokens) as a non-admin user while passing a different user's userId, e.g. tampering with the userId path/query parameter or a UI sending the wrong id.
Common situations: Frontend caching another user's id after account switching; API consumers iterating userIds to enumerate tokens; automated scripts reusing a general-user PAT to fetch other users' tokens.
Understand the failure class
Background: Permission denied / not authorized / 403 Forbidden: access-control rejections when the caller lacks the required role, grant, or ownership — this error's family across 18 libraries.
Related errors
- user %s doesn't have permission of %s %s
- REQUEST_PARAMS_NOT_VALID_ERROR
- ACCESS_TOKEN_NOT_EXIST
- USER_NO_OPERATION_PERM
- USER_NO_OPERATION_PROJECT_PERM
AI-assisted analysis of apache/dolphinscheduler@02eac45a1b (2026-09-06).
Data as JSON: /api/errors/3abd61eb7ba9b303.
Report an issue: GitHub.