{"record":{"id":"f545a2c9c8bf2f64","repo":"chenhg5/cc-connect","slug":"qq-sendfile-private-w","errorCode":null,"errorMessage":"qq: SendFile private: %w","messagePattern":"qq: SendFile private: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"platform/qq/qq.go","lineNumber":795,"sourceCode":"\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)\n","sourceCodeStart":777,"sourceCodeEnd":801,"githubUrl":"https://github.com/chenhg5/cc-connect/blob/4000b2338aa6e850c99df54f8b0ed6ed7460b401/platform/qq/qq.go#L777-L801","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["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.","Verify rctx.userID is the correct recipient and the bot account can message them.","Check the NapCat HTTP endpoint is reachable and the base64 payload is within limits (try a small file).","Retry after transient failures; verify the recipient has not blocked the bot."],"exampleFix":"// before\nif err != nil {\n\treturn fmt.Errorf(\"qq: SendFile private: %w\", err)\n}\n// after\nif err != nil {\n\treturn fmt.Errorf(\"qq: SendFile private to user %d (%s): %w\", rctx.userID, name, err) // adds user + file name context\n}","handlingStrategy":"try-catch","validationCode":"if rctx.userID == 0 {\n\treturn fmt.Errorf(\"not a private message; cannot send private file\")\n}","typeGuard":null,"tryCatchPattern":"if err := platform.SendFile(ctx, replyCtx, file); err != nil {\n\tslog.Error(\"private file send failed\", \"err\", err)\n\t// if cause mentions friendship, prompt the user to add the bot as a friend\n}","preventionTips":["Ensure the bot and recipient are QQ friends — private file sends to strangers are rejected.","Test with a small file first to rule out payload-size limits.","Verify NapCat HTTP API connectivity before assuming a QQ-side rejection.","Respect recipient privacy settings; offer an alternative delivery (e.g. group upload) on failure."],"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"}