{"record":{"id":"302e6ce1e47c360a","repo":"chenhg5/cc-connect","slug":"qq-send-image-w","errorCode":null,"errorMessage":"qq: send image: %w","messagePattern":"qq: send image: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"platform/qq/qq.go","lineNumber":488,"sourceCode":"\trctx, ok := replyCtx.(*replyContext)\n\tif !ok {\n\t\treturn fmt.Errorf(\"qq: SendImage: invalid reply context type %T\", replyCtx)\n\t}\n\n\tb64 := base64.StdEncoding.EncodeToString(img.Data)\n\tsegments := []map[string]any{\n\t\t{\"type\": \"image\", \"data\": map[string]any{\"file\": \"base64://\" + b64}},\n\t}\n\n\tparams := map[string]any{\n\t\t\"message\": segments,\n\t}\n\n\tif rctx.messageType == \"group\" {\n\t\tparams[\"group_id\"] = rctx.groupID\n\t\t_, err := p.callAPI(\"send_group_msg\", params)\n\t\tif err != nil {\n\t\t\treturn fmt.Errorf(\"qq: send image: %w\", err)\n\t\t}\n\t\treturn nil\n\t}\n\n\tparams[\"user_id\"] = rctx.userID\n\t_, err := p.callAPI(\"send_private_msg\", params)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"qq: send image: %w\", err)\n\t}\n\treturn nil\n}\n\nvar _ core.ImageSender = (*Platform)(nil)\n\nfunc (p *Platform) Stop() error {\n\tif p.cancel != nil {\n\t\tp.cancel()\n\t}","sourceCodeStart":470,"sourceCodeEnd":506,"githubUrl":"https://github.com/chenhg5/cc-connect/blob/4000b2338aa6e850c99df54f8b0ed6ed7460b401/platform/qq/qq.go#L470-L506","documentation":"Wraps a failure from callAPI(\"send_group_msg\", ...) inside SendImage when the reply context is a group chat. The OneBot WebSocket API call itself failed — the error carries the underlying cause (ws write failure, invalid response, retcode failure, or 15s timeout).","triggerScenarios":"Sending an image to a group when the WebSocket connection is broken (write fails), the OneBot side rejects the action (nonzero retcode, e.g. bot not in group), the response JSON cannot be parsed, or no response arrives within 15 seconds.","commonSituations":"Bot kicked out of or never added to the target group; OneBot connection dropped mid-send; image base64 payload too large for the WS path; OneBot server busy and slow to respond.","solutions":["Inspect the wrapped cause: retcode errors name the OneBot failure; timeouts suggest reconnecting the WS session.","Confirm the bot is a member of the target group and has permission to send images there.","If the image is large, use the HTTP API path (callHTTPAPI / upload_group_file) — WS message size limits can break large payloads.","Reconnect the platform (restart Start) if the underlying error is a ws write failure on a stale connection.","Retry once after a transient timeout; OneBot can be briefly unresponsive under load."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"if err := p.SendImage(ctx, replyCtx, img); err != nil {\n    var apiErr = err.Error()\n    switch {\n    case strings.Contains(apiErr, \"retcode\"):\n        slog.Error(\"onebot rejected group image\", \"err\", err) // check bot membership/permissions\n    case strings.Contains(apiErr, \"timeout\"):\n        time.Sleep(retryDelay); return p.SendImage(ctx, replyCtx, img)\n    case strings.Contains(apiErr, \"ws write\"):\n        return p.reconnect(ctx)\n    }\n    return err\n}","preventionTips":["Verify bot group membership before bulk image sends","Prefer the HTTP upload path for large images","Monitor WS connection health and reconnect on write errors","Log retcode values to a dashboard to spot permission/risk-control patterns"],"tags":["websocket","onebot","image","group-message","api-error"],"backgroundTag":"api-request-failed","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"}