{"record":{"id":"5d792b758c381c3d","repo":"chenhg5/cc-connect","slug":"weixin-getconfig-ret-d-errcode-d-errmsg-s","errorCode":null,"errorMessage":"weixin: getConfig ret=%d errcode=%d errmsg=%s","messagePattern":"weixin: getConfig ret=(.+?) errcode=(.+?) errmsg=(.+?)","errorType":"error_code","errorClass":null,"httpStatus":null,"severity":"error","filePath":"platform/weixin/client.go","lineNumber":233,"sourceCode":"\treq := getConfigReq{\n\t\tUserID:       userID,\n\t\tContextToken: contextToken,\n\t\tBaseInfo:     baseInfo{ChannelVersion: channelVersion},\n\t}\n\tpayload, err := json.Marshal(req)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\traw, err := c.post(ctx, \"ilink/bot/getconfig\", payload, 0, \"getConfig\")\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tvar out getConfigResp\n\tif err := json.Unmarshal(raw, &out); err != nil {\n\t\treturn nil, fmt.Errorf(\"weixin: getConfig json: %w\", err)\n\t}\n\tif out.Ret != 0 || out.Errcode != 0 {\n\t\treturn nil, fmt.Errorf(\"weixin: getConfig ret=%d errcode=%d errmsg=%s\", out.Ret, out.Errcode, out.Errmsg)\n\t}\n\treturn &out, nil\n}\n\nfunc (c *apiClient) sendTyping(ctx context.Context, userID, typingTicket string, status int) error {\n\treq := sendTypingReq{\n\t\tIlinkUserID:  userID,\n\t\tTypingTicket: typingTicket,\n\t\tStatus:       status,\n\t\tBaseInfo:     baseInfo{ChannelVersion: channelVersion},\n\t}\n\tpayload, err := json.Marshal(req)\n\tif err != nil {\n\t\treturn err\n\t}\n\t_, err = c.post(ctx, \"ilink/bot/sendtyping\", payload, 0, \"sendTyping\")\n\treturn err\n}","sourceCodeStart":215,"sourceCodeEnd":251,"githubUrl":"https://github.com/chenhg5/cc-connect/blob/4000b2338aa6e850c99df54f8b0ed6ed7460b401/platform/weixin/client.go#L215-L251","documentation":"The getconfig endpoint returned valid JSON but reported failure via non-zero Ret or Errcode. The client surfaces ret/errcode/errmsg as an error so the typing-ticket flow (getTypingTicket) fails fast with the API's own reason.","triggerScenarios":"WeChat rejects getconfig for this userID/contextToken: expired or invalid session, wrong user identifier, or server-side restriction reported through ret/errcode/errmsg.","commonSituations":"Stale context_token after account re-login; querying config for a user the bot no longer shares a session with; temporary WeChat-side incidents.","solutions":["Read ret/errcode/errmsg from the error to determine the API's cause","Re-authenticate and refresh the context token, then retry getConfig","Verify the userID matches an active conversation with the bot","Add retry with backoff for transient errcodes"],"exampleFix":null,"handlingStrategy":"retry","validationCode":"if out.Ret != 0 || out.Errcode != 0 { /* check before using the config/typing ticket */ }","typeGuard":"func (r *getConfigResp) ok() bool { return r != nil && r.Ret == 0 && r.Errcode == 0 }","tryCatchPattern":"ticket, err := getTypingTicket(ctx, userID)\nif err != nil {\n\tif strings.Contains(err.Error(), \"getConfig ret=\") {\n\t\trefreshSession(); time.Sleep(backoff); return retry()\n\t}\n\treturn err\n}","preventionTips":["Re-authenticate on auth-related errcodes before retrying typing calls","Validate userID corresponds to an active conversation","Add exponential backoff for transient API refusals"],"tags":["weixin","api-error","config","typing"],"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"}