chenhg5/cc-connect · error

weixin: getConfig ret=%d errcode=%d errmsg=%s

Error message

weixin: getConfig ret=%d errcode=%d errmsg=%s

What it means

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.

Source

Thrown at platform/weixin/client.go:233

	req := getConfigReq{
		UserID:       userID,
		ContextToken: contextToken,
		BaseInfo:     baseInfo{ChannelVersion: channelVersion},
	}
	payload, err := json.Marshal(req)
	if err != nil {
		return nil, err
	}
	raw, err := c.post(ctx, "ilink/bot/getconfig", payload, 0, "getConfig")
	if err != nil {
		return nil, err
	}
	var out getConfigResp
	if err := json.Unmarshal(raw, &out); err != nil {
		return nil, fmt.Errorf("weixin: getConfig json: %w", err)
	}
	if out.Ret != 0 || out.Errcode != 0 {
		return nil, fmt.Errorf("weixin: getConfig ret=%d errcode=%d errmsg=%s", out.Ret, out.Errcode, out.Errmsg)
	}
	return &out, nil
}

func (c *apiClient) sendTyping(ctx context.Context, userID, typingTicket string, status int) error {
	req := sendTypingReq{
		IlinkUserID:  userID,
		TypingTicket: typingTicket,
		Status:       status,
		BaseInfo:     baseInfo{ChannelVersion: channelVersion},
	}
	payload, err := json.Marshal(req)
	if err != nil {
		return err
	}
	_, err = c.post(ctx, "ilink/bot/sendtyping", payload, 0, "sendTyping")
	return err
}

View on GitHub (pinned to 4000b2338a)

Solutions

  1. Read ret/errcode/errmsg from the error to determine the API's cause
  2. Re-authenticate and refresh the context token, then retry getConfig
  3. Verify the userID matches an active conversation with the bot
  4. Add retry with backoff for transient errcodes
Defensive patterns

Strategy: retry

Validate before calling

if out.Ret != 0 || out.Errcode != 0 { /* check before using the config/typing ticket */ }

Type guard

func (r *getConfigResp) ok() bool { return r != nil && r.Ret == 0 && r.Errcode == 0 }

Try / catch

ticket, err := getTypingTicket(ctx, userID)
if err != nil {
	if strings.Contains(err.Error(), "getConfig ret=") {
		refreshSession(); time.Sleep(backoff); return retry()
	}
	return err
}

Prevention

When it happens

Trigger: WeChat rejects getconfig for this userID/contextToken: expired or invalid session, wrong user identifier, or server-side restriction reported through ret/errcode/errmsg.

Common situations: Stale context_token after account re-login; querying config for a user the bot no longer shares a session with; temporary WeChat-side incidents.

Related errors


AI-assisted analysis of chenhg5/cc-connect@4000b2338a (2026-09-06). Data as JSON: /api/errors/5d792b758c381c3d. Report an issue: GitHub.