{"record":{"id":"1256a6f06d6bb2ea","repo":"iflytek/astron-agent","slug":"current-user-does-not-exist","errorCode":null,"errorMessage":"Current user does not exist","messagePattern":"Current user does not exist","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"console/backend/commons/src/main/java/com/iflytek/astron/console/commons/data/impl/UserInfoDataServiceImpl.java","lineNumber":413,"sourceCode":"        userInfoMapper.updateById(userInfo);\n\n        // If the nickname has changed, publish an event\n        if (StringUtils.isNotBlank(nickname) && !nickname.equals(oldNickname)) {\n            eventPublisher.publishEvent(new UserNicknameUpdatedEvent(this, uid, oldNickname, nickname));\n            log.info(\"Published nickname update event for uid: {}, oldNickname: {}, newNickname: {}\",\n                    uid, oldNickname, nickname);\n        }\n\n        return userInfo;\n    }\n\n    @Override\n    public UserInfo updateCurrentUserBasicInfo(String nickname, String avatar) {\n        String currentUid = RequestContextUtil.getUID();\n        Optional<UserInfo> userInfoOpt = findByUid(currentUid);\n\n        if (userInfoOpt.isEmpty()) {\n            throw new IllegalArgumentException(\"Current user does not exist\");\n        }\n\n        UserInfo userInfo = userInfoOpt.get();\n        String oldNickname = userInfo.getNickname();\n\n        if (StringUtils.isNotBlank(nickname)) {\n            userInfo.setNickname(nickname);\n        }\n        if (StringUtils.isNotBlank(avatar)) {\n            userInfo.setAvatar(avatar);\n        }\n        userInfo.setUpdateTime(LocalDateTime.now());\n        userInfoMapper.updateById(userInfo);\n\n        // If the nickname has changed, publish an event\n        if (StringUtils.isNotBlank(nickname) && !nickname.equals(oldNickname)) {\n            eventPublisher.publishEvent(new UserNicknameUpdatedEvent(this, currentUid, oldNickname, nickname));\n            log.info(\"Published nickname update event for uid: {}, oldNickname: {}, newNickname: {}\",","sourceCodeStart":395,"sourceCodeEnd":431,"githubUrl":"https://github.com/iflytek/astron-agent/blob/5e758547a83371a5a4b29dadf4ac03e8dd527635/console/backend/commons/src/main/java/com/iflytek/astron/console/commons/data/impl/UserInfoDataServiceImpl.java#L395-L431","documentation":"updateCurrentUserBasicInfo reads the UID from the request context (RequestContextUtil.getUID) and looks up the user; if no UserInfo row exists for that UID it throws IllegalArgumentException. This means the authenticated identity in the request context does not correspond to a persisted user record.","triggerScenarios":"Calling updateCurrentUserBasicInfo when the authenticated user's row was deleted (or never synced) after login; RequestContextUtil.getUID() returning an identifier absent from the user_info table.","commonSituations":"Stale sessions/tokens after a user was removed from the DB; environments where the auth token's subject differs from the local user table (e.g. misconfigured SSO or multi-tenant UID mismatch); data restored from backups without users.","solutions":["Verify a user_info row exists for the UID returned by RequestContextUtil.getUID()","Check the auth/SSO configuration so the token subject maps to the correct local UID","Clear stale sessions/tokens after user deletion so revoked identities cannot call this API","Catch the IllegalArgumentException in the controller and return 401/404 prompting re-login"],"exampleFix":"// before\nString uid = RequestContextUtil.getUID();\nservice.updateCurrentUserBasicInfo(nickname, avatar);\n// after\nString uid = RequestContextUtil.getUID();\nif (userInfoDataService.findByUid(uid).isEmpty()) {\n    throw new BusinessException(ResponseEnum.DATA_NOT_FOUND, \"please re-login\");\n}\nservice.updateCurrentUserBasicInfo(nickname, avatar);","handlingStrategy":"try-catch","validationCode":"boolean currentUserExists = userInfoDataService.findByUid(RequestContextUtil.getUID()).isPresent();","typeGuard":null,"tryCatchPattern":"try { service.updateCurrentUserBasicInfo(nickname, avatar); } catch (IllegalArgumentException e) { return unauthorized(\"Please re-login\"); }","preventionTips":["Invalidate sessions when users are deleted","Keep token subject and local user table in sync (SSO/tenant mapping tests)","Return 401 prompting re-login rather than 500 on identity mismatch"],"tags":["user-not-found","auth-context","java"],"backgroundTag":"user-not-found","analyzedSha":"5e758547a83371a5a4b29dadf4ac03e8dd527635","analyzedAt":"2026-09-12T08:03:51.356Z","contentChangedAt":"2026-09-12T08:03:51.356Z","schemaVersion":2},"datasetVersion":"2026-09-15T23:17:13.987Z"}