apache/dolphinscheduler · error · ServiceException
ACCESS_TOKEN_NOT_EXIST
ACCESS_TOKEN_NOT_EXIST
Error message
ACCESS_TOKEN_NOT_EXIST
What it means
deleteAccessTokenById looks up the token row by id via accessTokenDao.queryById; when no row exists it throws ServiceException(Status.ACCESS_TOKEN_NOT_EXIST, id). The id does not correspond to any access token stored in the database.
Source
Thrown at dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/AccessTokenServiceImpl.java:168
return EncryptionUtils.getMd5(userId + expireTime + System.currentTimeMillis());
}
/**
* delete access token
*
* @param loginUser login user
* @param id token id
* @return delete result code
*/
@Override
public void deleteAccessTokenById(User loginUser, int id) {
if (!canOperatorPermissions(loginUser, null, AuthorizationType.ACCESS_TOKEN, ACCESS_TOKEN_DELETE)) {
throw new ServiceException(Status.USER_NO_OPERATION_PERM);
}
AccessToken accessToken = accessTokenDao.queryById(id);
if (accessToken == null) {
throw new ServiceException(Status.ACCESS_TOKEN_NOT_EXIST, id);
}
// admin can operate all, non-admin can operate their own
if (accessToken.getUserId() != loginUser.getId() && !loginUser.getUserType().equals(UserType.ADMIN_USER)) {
throw new ServiceException(Status.USER_NO_OPERATION_PERM);
}
accessTokenDao.deleteById(id);
}
/**
* update token by id
*
* @param id token id
* @param userId token for user
* @param expireTime token expire time
* @param token token string (if it is absent, it will be automatically generated)
* @return updated access token entity
*/View on GitHub (pinned to 02eac45a1b)
Solutions
- Refresh the token list (GET /access-tokens) and delete using a valid, current id.
- Guard against duplicate deletes in your client (ignore 404-style responses or remove the item after the first success).
- Verify you are connected to the same environment/database where the token was created.
- If the token should exist, check the DB access_token table directly to confirm its current id.
Example fix
// before: deleting a stale id curl -X DELETE .../access-tokens/999 // ACCESS_TOKEN_NOT_EXIST // after: fetch current list, then delete a real id ids=$(curl .../access-tokens | jq '.data[].id'); curl -X DELETE .../access-tokens/$id
Defensive patterns
Strategy: try-catch
Validate before calling
// confirm the id exists before deleting
List<AccessToken> tokens = accessTokenService.queryAccessTokenByUser(loginUser, loginUser.getId());
boolean exists = tokens.stream().anyMatch(t -> t.getId() == id);
if (!exists) throw new IllegalStateException("Token id " + id + " does not exist"); Type guard
boolean tokenExists(int id, List<AccessToken> tokens) {
return tokens != null && tokens.stream().anyMatch(t -> t.getId() == id);
} Try / catch
try {
accessTokenService.deleteAccessTokenById(loginUser, id);
} catch (ServiceException e) {
if (e.getCode() == Status.ACCESS_TOKEN_NOT_EXIST) {
log.warn("Token {} already gone; treating delete as idempotent success", id);
return; // idempotent delete
}
throw e;
} Prevention
- Refresh the token list before deleting; never reuse cached ids.
- Treat NOT_EXIST on delete as success to make operations idempotent.
- Verify client points at the same environment/database the token lives in.
- Avoid double-submit delete buttons in UI tooling.
When it happens
Trigger: Calling DELETE /access-tokens/{id} with an id that was already deleted, never existed, belongs to another environment/database, or was fabricated by the client.
Common situations: Double-deletes or retrying after a successful deletion; UI cache showing a stale token list; pointing the client at a different DolphinScheduler database than where the token was created; hard-coding ids from documentation.
Understand the failure class
Background: Record Not Found Errors: "not found", RecordNotFound, and "was not found" — what they mean and how to fix them — this error's family across 28 libraries.
Related errors
- USER_NO_OPERATION_PERM
- REQUEST_PARAMS_NOT_VALID_ERROR
- RESOURCE_NOT_EXIST
- PROJECT_NOT_EXIST
- PROJECT_NOT_FOUND
AI-assisted analysis of apache/dolphinscheduler@02eac45a1b (2026-09-06).
Data as JSON: /api/errors/84a133c5648fe204.
Report an issue: GitHub.