iflytek/astron-agent · error · BusinessException

NOTIFICATION_TYPE_INVALID

NOTIFICATION_TYPE_INVALID

Error message

NOTIFICATION_TYPE_INVALID

What it means

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.

Solutions

  1. Use one of the supported types: BROADCAST, PERSONAL, SYSTEM, PROMOTION.
  2. If a new enum constant is intended, add a case to the switch in NotificationServiceImpl.sendNotification and re-sync client/server enum definitions.
  3. Ensure client and server deploy the same version of the NotificationType enum.

Example fix

// before
request.setType(NotificationType.PUSH); // unhandled constant
// after
request.setType(NotificationType.PROMOTION);
Defensive patterns

Strategy: validation

Validate before calling

const allowed = ['BROADCAST','PERSONAL','SYSTEM','PROMOTION']; if (!allowed.includes(req.type)) { throw new Error('unsupported notification type: ' + req.type); }

Type guard

function isSupportedType(t) { return ['BROADCAST','PERSONAL','SYSTEM','PROMOTION'].includes(t); }

Try / catch

try { sendNotification(req); } catch (BusinessException e) { if (e.getCode() == ResponseEnum.NOTIFICATION_TYPE_INVALID.getCode()) { /* map or drop unknown type */ } }

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Understand the failure class

Background: Invalid enum value errors: "Unknown type", "Invalid scope", "must be one of" — when a string is not on the library's allowed list — this error's family across 23 libraries.

Related errors


AI-assisted analysis of iflytek/astron-agent@5e758547a8 (2026-09-12). Data as JSON: /api/errors/2c53f5e5e423ac06. Report an issue: GitHub.

Appendix: source

Thrown at console/backend/hub/src/main/java/com/iflytek/astron/console/hub/service/notification/impl/NotificationServiceImpl.java:55

    @Override
    @Transactional
    public Long sendNotification(SendNotificationRequest request) {
        // Parameter validation
        if (request == null || request.getType() == null) {
            throw new BusinessException(ResponseEnum.PARAMETER_ERROR);
        }

        NotificationType notificationType = request.getType();

        // Route to different processing logic based on message type
        switch (notificationType) {
            case BROADCAST:
                return sendBroadcastNotificationInternal(request);
            case PERSONAL, SYSTEM, PROMOTION:
                return sendToUsersNotificationInternal(request, notificationType);
            default:
                throw new BusinessException(ResponseEnum.NOTIFICATION_TYPE_INVALID);
        }
    }

    // ==================== Query Notification ====================

    @Override
    public NotificationPageResponse getUserNotifications(String receiverUid, NotificationQueryRequest queryRequest) {
        return getUserNotificationsByUid(receiverUid, queryRequest);
    }

    @Override
    public long getUnreadNotificationCount(String receiverUid) {
        if (receiverUid == null) {
            throw new BusinessException(ResponseEnum.PARAMETER_ERROR);
        }
        return notificationDataService.countUserUnreadNotifications(receiverUid);
    }

View on GitHub (pinned to 5e758547a8)