{"record":{"id":"2c53f5e5e423ac06","repo":"iflytek/astron-agent","slug":"notification-type-invalid","errorCode":"NOTIFICATION_TYPE_INVALID","errorMessage":"NOTIFICATION_TYPE_INVALID","messagePattern":"NOTIFICATION_TYPE_INVALID","errorType":"error_code","errorClass":"BusinessException","httpStatus":null,"severity":"error","filePath":"console/backend/hub/src/main/java/com/iflytek/astron/console/hub/service/notification/impl/NotificationServiceImpl.java","lineNumber":55,"sourceCode":"\n    @Override\n    @Transactional\n    public Long sendNotification(SendNotificationRequest request) {\n        // Parameter validation\n        if (request == null || request.getType() == null) {\n            throw new BusinessException(ResponseEnum.PARAMETER_ERROR);\n        }\n\n        NotificationType notificationType = request.getType();\n\n        // Route to different processing logic based on message type\n        switch (notificationType) {\n            case BROADCAST:\n                return sendBroadcastNotificationInternal(request);\n            case PERSONAL, SYSTEM, PROMOTION:\n                return sendToUsersNotificationInternal(request, notificationType);\n            default:\n                throw new BusinessException(ResponseEnum.NOTIFICATION_TYPE_INVALID);\n        }\n    }\n\n    // ==================== Query Notification ====================\n\n    @Override\n    public NotificationPageResponse getUserNotifications(String receiverUid, NotificationQueryRequest queryRequest) {\n        return getUserNotificationsByUid(receiverUid, queryRequest);\n    }\n\n    @Override\n    public long getUnreadNotificationCount(String receiverUid) {\n        if (receiverUid == null) {\n            throw new BusinessException(ResponseEnum.PARAMETER_ERROR);\n        }\n        return notificationDataService.countUserUnreadNotifications(receiverUid);\n    }\n","sourceCodeStart":37,"sourceCodeEnd":73,"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#L37-L73","documentation":"sendNotification switches on the NotificationType enum; only BROADCAST, PERSONAL, SYSTEM, and PROMOTION are handled. Any other value falls to the default branch and throws BusinessException(ResponseEnum.NOTIFICATION_TYPE_INVALID). This guards against unhandled enum values, typically from newer enum constants not yet routed.","triggerScenarios":"Passing a NotificationType constant that has no case in the switch (an enum added to NotificationType but not wired in sendNotification), or an unrecognized type value that still binds to the enum.","commonSituations":"Version skew: client/server built against different NotificationType versions; a developer adds a new enum constant but forgets to add the switch case; copied enum from another module with extra values.","solutions":["Use one of the supported types: BROADCAST, PERSONAL, SYSTEM, PROMOTION.","If a new enum constant is intended, add a case to the switch in NotificationServiceImpl.sendNotification and re-sync client/server enum definitions.","Ensure client and server deploy the same version of the NotificationType enum."],"exampleFix":"// before\nrequest.setType(NotificationType.PUSH); // unhandled constant\n// after\nrequest.setType(NotificationType.PROMOTION);","handlingStrategy":"validation","validationCode":"const allowed = ['BROADCAST','PERSONAL','SYSTEM','PROMOTION']; if (!allowed.includes(req.type)) { throw new Error('unsupported notification type: ' + req.type); }","typeGuard":"function isSupportedType(t) { return ['BROADCAST','PERSONAL','SYSTEM','PROMOTION'].includes(t); }","tryCatchPattern":"try { sendNotification(req); } catch (BusinessException e) { if (e.getCode() == ResponseEnum.NOTIFICATION_TYPE_INVALID.getCode()) { /* map or drop unknown type */ } }","preventionTips":["Add a switch case for every new NotificationType constant when it is introduced.","Share a single NotificationType definition across client and server.","Add a unit test enumerating all enum values against sendNotification."],"tags":["notification","enum"],"backgroundTag":"invalid-enum-value","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"}