{"record":{"id":"2503003fdf869f6e","repo":"iflytek/astron-agent","slug":"notification-not-exists","errorCode":"NOTIFICATION_NOT_EXISTS","errorMessage":"NOTIFICATION_NOT_EXISTS","messagePattern":"NOTIFICATION_NOT_EXISTS","errorType":"error_code","errorClass":"BusinessException","httpStatus":null,"severity":"warning","filePath":"console/backend/hub/src/main/java/com/iflytek/astron/console/hub/service/notification/impl/NotificationServiceImpl.java","lineNumber":128,"sourceCode":"    @DistributedLock(\n            key = \"notification:delete:#{#receiverUid}\",\n            waitTime = 2L,\n            leaseTime = 5L,\n            failStrategy = DistributedLock.FailStrategy.CONTINUE,\n            description = \"Lock for deleting user messages\")\n    public boolean deleteNotification(String receiverUid, Long notificationId) {\n        if (receiverUid == null || notificationId == null) {\n            throw new BusinessException(ResponseEnum.PARAMETER_ERROR);\n        }\n\n        try {\n            int deleted = notificationDataService.deleteUserNotification(receiverUid, notificationId);\n            if (deleted > 0) {\n                log.info(\"Notification deleted successfully, receiverUid: {}, notificationId: {}\",\n                        receiverUid, notificationId);\n                return true;\n            } else {\n                throw new BusinessException(ResponseEnum.NOTIFICATION_NOT_EXISTS);\n            }\n        } catch (BusinessException e) {\n            throw e; // Re-throw business exception\n        } catch (Exception e) {\n            log.error(\"Failed to delete notification, receiverUid: {}, notificationId: {}\",\n                    receiverUid, notificationId, e);\n            throw new BusinessException(ResponseEnum.NOTIFICATION_DELETE_FAILED);\n        }\n    }\n\n    // ==================== System Management ====================\n\n    @Override\n    @Transactional\n    public int cleanExpiredNotifications() {\n        try {\n            LocalDateTime expireTime = LocalDateTime.now();\n            int deleted = notificationDataService.deleteExpiredNotifications(expireTime);","sourceCodeStart":110,"sourceCodeEnd":146,"githubUrl":"https://github.com/iflytek/astron-agent/blob/5e758547a83371a5a4b29dadf4ac03e8dd527635/console/backend/hub/src/main/java/com/iflytek/astron/console/hub/service/notification/impl/NotificationServiceImpl.java#L110-L146","documentation":"When deleteUserNotification reports zero deleted rows, the service concludes the notification does not exist for that user and throws BusinessException(ResponseEnum.NOTIFICATION_NOT_EXISTS). BusinessException is rethrown as-is, so this error specifically means 'no matching row', unlike generic failures.","triggerScenarios":"Deleting an already-deleted notification; using a notificationId belonging to another user (uid/id mismatch); stale UI lists retrying deletes of purged rows; wrong tenant/space data isolation causing lookup to miss.","commonSituations":"Double-click on delete buttons firing the request twice; cached notification lists out of sync with DB; cross-environment ids (test id used in prod).","solutions":["Confirm the notificationId exists and belongs to the given receiverUid before deleting.","Handle NOTIFICATION_NOT_EXISTS idempotently on the client (treat repeat deletes as success).","Refresh the notification list after deletes so stale ids are not reused.","Check tenant/space filters if the row exists but scoped queries cannot see it."],"exampleFix":"// before\ndeleteNotification(uid, id); // id already removed, throws\n// after\ntry {\n    deleteNotification(uid, id);\n} catch (BusinessException e) {\n    // treat NOTIFICATION_NOT_EXISTS as already-deleted success\n}","handlingStrategy":"try-catch","validationCode":"if (!knownNotificationIds.has(notificationId)) { refreshList(); return; }","typeGuard":null,"tryCatchPattern":"try { deleteNotification(uid, id); } catch (BusinessException e) { if (e.getCode() == ResponseEnum.NOTIFICATION_NOT_EXISTS.getCode()) { /* treat as already deleted: remove from local list, no error */ } }","preventionTips":["Treat NOTIFICATION_NOT_EXISTS as idempotent success in clients.","Refresh lists after deletes to avoid stale ids.","Avoid reusing ids across environments."],"tags":["notification","not-found"],"backgroundTag":"record-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"}