chenhg5/cc-connect · error

dingtalk: send reply: %w

Error message

dingtalk: send reply: %w

What it means

Wrapped network/transport error from posting the JSON reply payload to the DingTalk session webhook; the request to rc.sessionWebhook itself failed (timeout, DNS, connection refused) before any status code was received.

Source

Thrown at platform/dingtalk/dingtalk.go:830

		payload["at"] = map[string]any{
			"atUserIds": atUsers,
			"isAtAll":   atAll,
		}
	}
	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)

View on GitHub (pinned to 4000b2338a)

Solutions

  1. DingTalk session webhooks expire — reply promptly or use proactive send
  2. Retry on transient network failures
Defensive patterns

Strategy: retry

When it happens

Trigger: Thrown at platform/dingtalk/dingtalk.go:830 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/fc78bb16df5479ac. Report an issue: GitHub.