chenhg5/cc-connect · error

dingtalk: create request: %w

Error message

dingtalk: create request: %w

What it means

ReplyWithAt could not construct the http.Request posting the at-annotated reply to the session webhook (typically a malformed webhook URL). Wraps http.NewRequestWithContext's error before any network I/O.

Source

Thrown at platform/dingtalk/dingtalk.go:824

	payload := map[string]any{
		"msgtype": "text",
		"text":    map[string]string{"content": content},
	}
	if len(atUsers) > 0 || atAll {
		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 {

View on GitHub (pinned to 4000b2338a)

Solutions

  1. Re-derive the session webhook by receiving a fresh message
  2. Check the stored sessionWebhook URL for corruption
Defensive patterns

Strategy: try-catch

When it happens

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