apache/shenyu · error · AlertNoticeException

Http StatusCode " + responseEntity.getStatusCode()

Error message

Http StatusCode " + responseEntity.getStatusCode()

What it means

The same send() throws AlertNoticeException("Http StatusCode " + statusCode) when the DingTalk webhook returns a non-200 HTTP status. It signals the HTTP request itself failed at transport/server level rather than a DingTalk logical error. The response body is logged but not included in the exception.

Solutions

  1. Verify the webhook URL and access_token are still valid (send a manual curl POST)
  2. Recreate the robot and update the webhook URL in alert config if it was deleted/rotated
  3. Check proxy/firewall settings between the app and oapi.dingtalk.com
  4. Inspect the logged response body ('Send dingTalk webHook ... Failed') for server-side details
Defensive patterns

Strategy: retry

Validate before calling

// pre-validate webhook URL shape and reachability
if (!webHookUrl.startsWith("https://oapi.dingtalk.com/robot/send")) {
    throw new IllegalArgumentException("invalid dingtalk webhook url");
}

Try / catch

try {
    strategy.send(config, alert);
} catch (AlertNoticeException e) {
    if (e.getMessage().startsWith("Http StatusCode")) {
        // retry with backoff or switch to fallback channel
    }
}

Prevention

When it happens

Trigger: POST to the DingTalk webhook URL returns 4xx/5xx: invalid/expired access_token (400), deleted robot (404), gateway or proxy errors (5xx).

Common situations: Webhook URL revoked or bot deleted; wrong URL copied from another group; corporate proxy returning errors; DingTalk-side outage returning 5xx.

Understand the failure class

Background: "API error: {status}" and "HTTP 401/403/404/429/5xx" errors: non-2xx HTTP responses explained — this error's family across 27 libraries.

Related errors


AI-assisted analysis of apache/shenyu@567142e072 (2026-09-12). Data as JSON: /api/errors/3c0a88e092c4d17c. Report an issue: GitHub.

Appendix: source

Thrown at shenyu-alert/src/main/java/org/apache/shenyu/alert/strategy/DingTalkRobotAlertNotifyStrategy.java:68

            markdownDTO.setTitle(alert.getTitle());
            dingTalkWebHookDto.setMarkdown(markdownDTO);
            HttpHeaders headers = new HttpHeaders();
            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.

View on GitHub (pinned to 567142e072)