{"record":{"id":"84a133c5648fe204","repo":"apache/dolphinscheduler","slug":"access-token-not-exist","errorCode":"ACCESS_TOKEN_NOT_EXIST","errorMessage":"ACCESS_TOKEN_NOT_EXIST","messagePattern":"ACCESS_TOKEN_NOT_EXIST","errorType":"error_code","errorClass":"ServiceException","httpStatus":null,"severity":"error","filePath":"dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/AccessTokenServiceImpl.java","lineNumber":168,"sourceCode":"        return EncryptionUtils.getMd5(userId + expireTime + System.currentTimeMillis());\n    }\n\n    /**\n     * delete access token\n     *\n     * @param loginUser login user\n     * @param id        token id\n     * @return delete result code\n     */\n    @Override\n    public void deleteAccessTokenById(User loginUser, int id) {\n        if (!canOperatorPermissions(loginUser, null, AuthorizationType.ACCESS_TOKEN, ACCESS_TOKEN_DELETE)) {\n            throw new ServiceException(Status.USER_NO_OPERATION_PERM);\n        }\n\n        AccessToken accessToken = accessTokenDao.queryById(id);\n        if (accessToken == null) {\n            throw new ServiceException(Status.ACCESS_TOKEN_NOT_EXIST, id);\n        }\n\n        // admin can operate all, non-admin can operate their own\n        if (accessToken.getUserId() != loginUser.getId() && !loginUser.getUserType().equals(UserType.ADMIN_USER)) {\n            throw new ServiceException(Status.USER_NO_OPERATION_PERM);\n        }\n        accessTokenDao.deleteById(id);\n    }\n\n    /**\n     * update token by id\n     *\n     * @param id         token id\n     * @param userId     token for user\n     * @param expireTime token expire time\n     * @param token      token string (if it is absent, it will be automatically generated)\n     * @return updated access token entity\n     */","sourceCodeStart":150,"sourceCodeEnd":186,"githubUrl":"https://github.com/apache/dolphinscheduler/blob/02eac45a1b6676e639fcbfb4be2243de5771b05d/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/AccessTokenServiceImpl.java#L150-L186","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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."],"exampleFix":"// before: deleting a stale id\ncurl -X DELETE .../access-tokens/999   // ACCESS_TOKEN_NOT_EXIST\n\n// after: fetch current list, then delete a real id\nids=$(curl .../access-tokens | jq '.data[].id'); curl -X DELETE .../access-tokens/$id","handlingStrategy":"try-catch","validationCode":"// confirm the id exists before deleting\nList<AccessToken> tokens = accessTokenService.queryAccessTokenByUser(loginUser, loginUser.getId());\nboolean exists = tokens.stream().anyMatch(t -> t.getId() == id);\nif (!exists) throw new IllegalStateException(\"Token id \" + id + \" does not exist\");","typeGuard":"boolean tokenExists(int id, List<AccessToken> tokens) {\n    return tokens != null && tokens.stream().anyMatch(t -> t.getId() == id);\n}","tryCatchPattern":"try {\n    accessTokenService.deleteAccessTokenById(loginUser, id);\n} catch (ServiceException e) {\n    if (e.getCode() == Status.ACCESS_TOKEN_NOT_EXIST) {\n        log.warn(\"Token {} already gone; treating delete as idempotent success\", id);\n        return; // idempotent delete\n    }\n    throw e;\n}","preventionTips":["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."],"tags":["access-token","not-found","api","rest"],"backgroundTag":"record-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"}