chenhg5/cc-connect · error
qq: SendFile group: %w
Error message
qq: SendFile group: %w
What it means
When sending a file to a QQ group, SendFile calls the NapCat/upload_group_file HTTP API with base64-encoded file data. If that API call returns an error, it is wrapped as "qq: SendFile group: %w", meaning the group file upload was rejected by the QQ/NapCat server.
Source
Thrown at platform/qq/qq.go:782
name = "attachment"
}
b64data := "base64://" + base64.StdEncoding.EncodeToString(file.Data)
// Pick API caller: prefer HTTP for large payloads, fall back to WebSocket.
call := p.callAPI
if p.httpURL != "" {
call = p.callHTTPAPI
}
if rctx.messageType == "group" {
_, err := call("upload_group_file", map[string]any{
"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
- Unwrap the error (%w) to see the underlying NapCat API message and act on that cause.
- Verify the bot is still a member of the group and has file-upload permission.
- Check the NapCat HTTP API endpoint/port is reachable and the file size is within QQ limits.
- Try a smaller test file to isolate size-related rejections; check rctx.groupID is populated (group messages only).
Example fix
// before
if err != nil {
return fmt.Errorf("qq: SendFile group: %w", err)
}
// after
if err != nil {
return fmt.Errorf("qq: SendFile group %d (%s): %w", rctx.groupID, name, err) // adds group + file name context
} Defensive patterns
Strategy: try-catch
Validate before calling
if rctx.groupID == 0 {
return fmt.Errorf("not a group message; cannot upload group file")
} Try / catch
if err := platform.SendFile(ctx, replyCtx, file); err != nil {
var wrapped interface{ Unwrap() error }
if errors.As(err, &cause) {
slog.Error("group file upload failed", "cause", cause)
}
// notify user with a fallback text message
} Prevention
- Keep the bot in the target groups with file-upload permission.
- Check NapCat HTTP endpoint health before large uploads.
- Validate file size against QQ group-file limits before sending.
- Surface a fallback text reply when file upload fails.
When it happens
Trigger: Sending a file attachment to a group via SendFile where the underlying upload_group_file call fails: bot lacks permission in the group, bot not in the group, NapCat HTTP API unreachable/erroring, or payload rejected (too large / bad base64).
Common situations: Bot removed from or lacking admin/upload rights in the target group. File exceeding QQ group-file size limits. NapCat service down or misconfigured HTTP endpoint. WSL/Docker networking blocking the NapCat port.
Related errors
- qq: SendFile private: %w
- discord: send image fallback: %w
- discord: send image: %w
- discord: send file fallback: %w
- discord: send file: %w
AI-assisted analysis of chenhg5/cc-connect@4000b2338a (2026-09-06).
Data as JSON: /api/errors/854e8882ccdb03f6.
Report an issue: GitHub.