apache/shenyu · error · AlertNoticeException
[DingTalk Notify Error] " + e.getMessage()
Error message
[DingTalk Notify Error] " + e.getMessage()
What it means
Catch-all in DingTalkRobotAlertNotifyStrategy.send: any Exception during building/sending the request (serialization, IO, timeout, NPE on body) is rethrown as AlertNoticeException("[DingTalk Notify Error] " + e.getMessage()). It indicates the notification pipeline failed before/at the HTTP call, and it also swallows the earlier AlertNoticeExceptions by re-wrapping them.
Solutions
- Check application logs for the root stack trace (the cause is preserved in the wrapping catch)
- Test webhook connectivity (timeout/DNS) from the host running the alert sender
- Increase RestTemplate connect/read timeouts if failures occur under load
- Handle empty/invalid response bodies explicitly instead of relying on requireNonNull
Example fix
// before
catch (Exception e) {
throw new AlertNoticeException("[DingTalk Notify Error] " + e.getMessage());
}
// after
catch (AlertNoticeException e) {
throw e;
} catch (Exception e) {
throw new AlertNoticeException("[DingTalk Notify Error] " + e.getMessage(), e);
} Defensive patterns
Strategy: try-catch
Validate before calling
// ensure webhook url set and network reachable before sending Objects.requireNonNull(webHookUrl, "dingtalk webhook url must be set");
Try / catch
try {
strategy.send(config, alert);
} catch (AlertNoticeException e) {
log.error("DingTalk notify failed: {}", e.getMessage(), e);
// use alternate notification strategy (email/sms)
} Prevention
- Set generous connect/read timeouts on the RestTemplate used for webhooks
- Test alert delivery after network changes or deployments
- Log the full cause of wrapped exceptions to speed diagnosis
When it happens
Trigger: Any exception inside send(): RestTemplate IO error, connect/read timeout, JSON serialization failure of the alert payload, or Objects.requireNonNull(responseEntity.getBody()) NPE on an empty body.
Common situations: Network outages or DNS failures reaching oapi.dingtalk.com; request timeouts under load; body unexpectedly empty so requireNonNull throws; alert content with characters that break serialization.
Related errors
- responseEntity.getBody().getErrMsg()
- Http StatusCode " + responseEntity.getStatusCode()
- Import mcp server config failed:
- Failed to get Swagger document, HTTP status code:
- Access to private or internal IP addresses is not allowed
AI-assisted analysis of apache/shenyu@567142e072 (2026-09-12).
Data as JSON: /api/errors/6b76d556b7e71801.
Report an issue: GitHub.
Appendix: source
Thrown at shenyu-alert/src/main/java/org/apache/shenyu/alert/strategy/DingTalkRobotAlertNotifyStrategy.java:71
headers.setContentType(MediaType.APPLICATION_JSON);
HttpEntity<DingTalkWebHookDto> httpEntity = new HttpEntity<>(dingTalkWebHookDto, headers);
String webHookUrl = DING_TALK_WEB_HOOK_URL + receiver.getAccessToken();
ResponseEntity<CommonRobotNotifyResp> responseEntity = getRestTemplate().postForEntity(webHookUrl,
httpEntity, CommonRobotNotifyResp.class);
if (responseEntity.getStatusCode() == HttpStatus.OK) {
Objects.requireNonNull(responseEntity.getBody());
if (responseEntity.getBody().getErrCode() == 0) {
log.debug("Send dingTalk webHook: {} Success", webHookUrl);
} else {
log.warn("Send dingTalk webHook: {} Failed: {}", webHookUrl, responseEntity.getBody().getErrMsg());
throw new AlertNoticeException(responseEntity.getBody().getErrMsg());
}
} else {
log.warn("Send dingTalk webHook: {} Failed: {}", webHookUrl, responseEntity.getBody());
throw new AlertNoticeException("Http StatusCode " + responseEntity.getStatusCode());
}
} catch (Exception e) {
throw new AlertNoticeException("[DingTalk Notify Error] " + e.getMessage());
}
}
@Override
public byte type() {
return 5;
}
@Override
protected String templateName() {
return "alertNotifyDingTalkRobot";
}
/**
* DingDing body.
*/
private static class DingTalkWebHookDto {
private static final String MARKDOWN = "markdown";View on GitHub (pinned to 567142e072)