{"record":{"id":"854e8882ccdb03f6","repo":"chenhg5/cc-connect","slug":"qq-sendfile-group-w","errorCode":null,"errorMessage":"qq: SendFile group: %w","messagePattern":"qq: SendFile group: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"platform/qq/qq.go","lineNumber":782,"sourceCode":"\t\tname = \"attachment\"\n\t}\n\n\tb64data := \"base64://\" + base64.StdEncoding.EncodeToString(file.Data)\n\n\t// Pick API caller: prefer HTTP for large payloads, fall back to WebSocket.\n\tcall := p.callAPI\n\tif p.httpURL != \"\" {\n\t\tcall = p.callHTTPAPI\n\t}\n\n\tif rctx.messageType == \"group\" {\n\t\t_, err := call(\"upload_group_file\", map[string]any{\n\t\t\t\"group_id\": rctx.groupID,\n\t\t\t\"file\":     b64data,\n\t\t\t\"name\":     name,\n\t\t})\n\t\tif err != nil {\n\t\t\treturn fmt.Errorf(\"qq: SendFile group: %w\", err)\n\t\t}\n\t\treturn nil\n\t}\n\n\t// Private: use send_private_msg with file segment\n\t_, err := call(\"send_private_msg\", map[string]any{\n\t\t\"user_id\": rctx.userID,\n\t\t\"message\": []map[string]any{\n\t\t\t{\"type\": \"file\", \"data\": map[string]any{\"file\": b64data, \"name\": name}},\n\t\t},\n\t})\n\tif err != nil {\n\t\treturn fmt.Errorf(\"qq: SendFile private: %w\", err)\n\t}\n\treturn nil\n}\n\nvar _ core.FileSender = (*Platform)(nil)","sourceCodeStart":764,"sourceCodeEnd":800,"githubUrl":"https://github.com/chenhg5/cc-connect/blob/4000b2338aa6e850c99df54f8b0ed6ed7460b401/platform/qq/qq.go#L764-L800","documentation":"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.","triggerScenarios":"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).","commonSituations":"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.","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)."],"exampleFix":"// before\nif err != nil {\n\treturn fmt.Errorf(\"qq: SendFile group: %w\", err)\n}\n// after\nif err != nil {\n\treturn fmt.Errorf(\"qq: SendFile group %d (%s): %w\", rctx.groupID, name, err) // adds group + file name context\n}","handlingStrategy":"try-catch","validationCode":"if rctx.groupID == 0 {\n\treturn fmt.Errorf(\"not a group message; cannot upload group file\")\n}","typeGuard":null,"tryCatchPattern":"if err := platform.SendFile(ctx, replyCtx, file); err != nil {\n\tvar wrapped interface{ Unwrap() error }\n\tif errors.As(err, &cause) {\n\t\tslog.Error(\"group file upload failed\", \"cause\", cause)\n\t}\n\t// notify user with a fallback text message\n}","preventionTips":["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."],"tags":["qq","file-upload","api-error"],"backgroundTag":"api-error-response","analyzedSha":"4000b2338aa6e850c99df54f8b0ed6ed7460b401","analyzedAt":"2026-09-06T11:45:09.575Z","contentChangedAt":"2026-09-06T11:45:09.575Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}