{"record":{"id":"178b6f2d2902ae4d","repo":"chenhg5/cc-connect","slug":"weixin-getconfig-json-w","errorCode":null,"errorMessage":"weixin: getConfig json: %w","messagePattern":"weixin: getConfig json: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"platform/weixin/client.go","lineNumber":230,"sourceCode":"}\n\nfunc (c *apiClient) getConfig(ctx context.Context, userID, contextToken string) (*getConfigResp, error) {\n\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}","sourceCodeStart":212,"sourceCodeEnd":248,"githubUrl":"https://github.com/chenhg5/cc-connect/blob/4000b2338aa6e850c99df54f8b0ed6ed7460b401/platform/weixin/client.go#L212-L248","documentation":"getConfig calls ilink/bot/getconfig to fetch per-user context configuration (used to obtain the typing ticket) and decodes the body into getConfigResp. This error wraps a json.Unmarshal failure: the reply is not valid JSON or no longer matches the struct.","triggerScenarios":"The getconfig endpoint returns non-JSON (HTML error page, empty/gateway body) or an iLink schema change breaks decoding into getConfigResp.","commonSituations":"Expired bot session causing an error page; proxy/WAF rewriting the body; WeChat iLink API protocol update.","solutions":["Capture the raw body for inspection (add truncateForLog to the error)","Refresh the bot session/ticket and retry","Update getConfigResp to the current API schema","Eliminate intermediaries that replace JSON with HTML"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"if userID == \"\" || contextToken == \"\" { return errors.New(\"weixin: getConfig requires userID and contextToken\") }","typeGuard":null,"tryCatchPattern":"cfg, err := getConfig(ctx, userID, token)\nif err != nil {\n\tif strings.Contains(err.Error(), \"getConfig json\") { refreshSession(); return retry() }\n\treturn err\n}","preventionTips":["Refresh the bot session when getconfig starts failing","Log raw bodies on unmarshal errors","Keep getConfigResp aligned with API changes"],"tags":["weixin","json","unmarshal","config"],"backgroundTag":"json-unmarshal-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"}