chenhg5/cc-connect · error

dingtalk: reply returned status %d

Error message

dingtalk: reply returned status %d

What it means

DingTalk's session webhook answered the reply POST with a non-200 status. Indicates webhook rejection (expired session webhook, invalid payload, rate limiting); the status code is embedded for diagnosis.

Source

Thrown at platform/dingtalk/dingtalk.go:835

	body, err := json.Marshal(payload)
	if err != nil {
		return fmt.Errorf("dingtalk: marshal reply: %w", err)
	}

	req, err := http.NewRequestWithContext(ctx, http.MethodPost, rc.sessionWebhook, bytes.NewReader(body))
	if err != nil {
		return fmt.Errorf("dingtalk: create request: %w", err)
	}
	req.Header.Set("Content-Type", "application/json")

	resp, err := core.HTTPClient.Do(req)
	if err != nil {
		return fmt.Errorf("dingtalk: send reply: %w", err)
	}
	defer func() { _ = resp.Body.Close() }()

	if resp.StatusCode != http.StatusOK {
		return fmt.Errorf("dingtalk: reply returned status %d", resp.StatusCode)
	}
	return nil
}

func (p *Platform) Reply(ctx context.Context, rctx any, content string) error {
	rc, ok := rctx.(replyContext)
	if !ok {
		return fmt.Errorf("dingtalk: invalid reply context type %T", rctx)
	}

	// Fall back to proactive API when sessionWebhook is unavailable
	if rc.proactive || rc.sessionWebhook == "" {
		return p.sendProactiveMessage(ctx, rc, content)
	}

	atUserIds := extractAtUserIds(content)

	content = preprocessDingTalkMarkdown(content)

View on GitHub (pinned to 4000b2338a)

Solutions

  1. Fall back to proactive send if the webhook expired
  2. Check the response body for sign/keyword rejection reasons
Defensive patterns

Strategy: retry

When it happens

Trigger: Thrown at platform/dingtalk/dingtalk.go:835 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of chenhg5/cc-connect@4000b2338a (2026-09-06). Data as JSON: /api/errors/b2d7bb75656c53b5. Report an issue: GitHub.