chenhg5/cc-connect · error

qq: SendFile private: %w

Error message

qq: SendFile private: %w

What it means

When sending a file in a private (direct) QQ chat, SendFile calls send_private_msg with a base64-encoded file segment. If that API call fails, the error is wrapped as "qq: SendFile private: %w", meaning the private file delivery was rejected by the QQ/NapCat server.

Source

Thrown at platform/qq/qq.go:795

			"group_id": rctx.groupID,
			"file":     b64data,
			"name":     name,
		})
		if err != nil {
			return fmt.Errorf("qq: SendFile group: %w", err)
		}
		return nil
	}

	// Private: use send_private_msg with file segment
	_, err := call("send_private_msg", map[string]any{
		"user_id": rctx.userID,
		"message": []map[string]any{
			{"type": "file", "data": map[string]any{"file": b64data, "name": name}},
		},
	})
	if err != nil {
		return fmt.Errorf("qq: SendFile private: %w", err)
	}
	return nil
}

var _ core.FileSender = (*Platform)(nil)

View on GitHub (pinned to 4000b2338a)

Solutions

  1. Unwrap the error to read the NapCat/QQ reason; "not friend" errors require the user to add the bot as a friend before private file sends work.
  2. Verify rctx.userID is the correct recipient and the bot account can message them.
  3. Check the NapCat HTTP endpoint is reachable and the base64 payload is within limits (try a small file).
  4. Retry after transient failures; verify the recipient has not blocked the bot.

Example fix

// before
if err != nil {
	return fmt.Errorf("qq: SendFile private: %w", err)
}
// after
if err != nil {
	return fmt.Errorf("qq: SendFile private to user %d (%s): %w", rctx.userID, name, err) // adds user + file name context
}
Defensive patterns

Strategy: try-catch

Validate before calling

if rctx.userID == 0 {
	return fmt.Errorf("not a private message; cannot send private file")
}

Try / catch

if err := platform.SendFile(ctx, replyCtx, file); err != nil {
	slog.Error("private file send failed", "err", err)
	// if cause mentions friendship, prompt the user to add the bot as a friend
}

Prevention

When it happens

Trigger: Sending a file attachment in a private chat via SendFile where the send_private_msg call fails: bot and user have no friend relationship (QQ requires this for private files), user blocked the bot, NapCat API error, or oversized payload.

Common situations: Bot and recipient are not QQ friends — QQ blocks private file sends to strangers. Recipient privacy settings block file messages. NapCat HTTP endpoint misconfigured or unreachable. Base64 body too large for the HTTP API limit.

Related errors


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