chenhg5/cc-connect · error

delete reaction failed: status=%d body=%s

Error message

delete reaction failed: status=%d body=%s

What it means

The WPS Xiezuo (协作) API returned a non-200 status for the reaction-delete call — the server rejected removing a reaction (expired message, missing permission, or invalid token), with the response body included for diagnosis.

Source

Thrown at platform/wps-xiezuo/wpsxiezuo.go:996

	body, _ := json.Marshal(reactionRequest{ReactionType: reactionType})
	url := fmt.Sprintf("%s/v7/chats/%s/messages/%s/reactions/delete", p.baseURL, rctx.ChatID, rctx.MessageID)

	req, err := http.NewRequestWithContext(ctx, http.MethodPost, url, bytes.NewReader(body))
	if err != nil {
		return err
	}
	req.Header.Set("Authorization", "Bearer "+token)
	req.Header.Set("Content-Type", "application/json")

	resp, err := http.DefaultClient.Do(req)
	if err != nil {
		return err
	}
	defer resp.Body.Close()

	if resp.StatusCode != http.StatusOK {
		respBody, _ := io.ReadAll(resp.Body)
		return fmt.Errorf("delete reaction failed: status=%d body=%s", resp.StatusCode, string(respBody))
	}
	return nil
}

// --- Optional interface: ReplyContextReconstructor ---

func (p *Platform) ReconstructReplyCtx(sessionKey string) (any, error) {
	// Formats:
	//   wps-xiezuo:{company_id}:{chat_id}             - group or legacy P2P
	//   wps-xiezuo:{company_id}:{chat_id}:{sender_id} - P2P, user-scoped
	parts := strings.SplitN(sessionKey, ":", 4)
	if len(parts) < 3 || parts[0] != "wps-xiezuo" {
		return nil, fmt.Errorf("wps-xiezuo: invalid session key %q", sessionKey)
	}
	rc := replyContext{
		ChatID:    parts[2],
		CompanyID: parts[1],
	}

View on GitHub (pinned to 4000b2338a)

Solutions

  1. Read the status and body in the error: 401/403 means refresh the token or fix permissions; 404 means the reaction no longer exists
  2. Refresh the OAuth access token and retry
  3. Verify the reaction ID is current; re-fetch reactions before deleting
  4. Check the bot/user has permission to modify the target document
Defensive patterns

Strategy: try-catch

Validate before calling

if resp.StatusCode == http.StatusUnauthorized { token = refreshToken(); retry() }

Try / catch

if err := deleteReaction(id); err != nil { var httpErr = err; if strings.Contains(err.Error(), "status=404") { return nil /* already deleted */ }; if strings.Contains(err.Error(), "status=401") { refreshToken(); retry() }; return httpErr }

Prevention

When it happens

Trigger: Calling the delete-reaction operation when the reaction ID is wrong/already deleted, the token is expired, or permissions on the doc/comment are insufficient.

Common situations: Stale reaction ID cached after another user removed the reaction; expired access token after hours of runtime; bot lacking edit permission on the document.

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 chenhg5/cc-connect@4000b2338a (2026-09-06). Data as JSON: /api/errors/cdd3204703cf7e40. Report an issue: GitHub.