chenhg5/cc-connect · error

api call: %w

Error message

api call: %w

What it means

Wraps a transport error from the raw SDK call p.client.Get("/open-apis/bot/v3/info") used by fetchBotOpenID to discover the bot's open_id. Thrown when the HTTP request to the Feishu bot-info API fails before a response can be parsed (network error, auth failure, client misconfiguration).

Source

Thrown at platform/feishu/feishu.go:3815

func findSingleAsterisk(s string) int {
	for i := 0; i < len(s); i++ {
		if s[i] == '*' {
			if i+1 < len(s) && s[i+1] == '*' {
				i++ // skip **
				continue
			}
			return i
		}
	}
	return -1
}

// fetchBotOpenID retrieves the bot's open_id via the Feishu bot info API.
func (p *Platform) fetchBotOpenID() (string, error) {
	resp, err := p.client.Get(context.Background(),
		"/open-apis/bot/v3/info", nil, larkcore.AccessTokenTypeTenant)
	if err != nil {
		return "", fmt.Errorf("api call: %w", err)
	}
	var result struct {
		Code int `json:"code"`
		Bot  struct {
			OpenID string `json:"open_id"`
		} `json:"bot"`
	}
	if err := json.Unmarshal(resp.RawBody, &result); err != nil {
		return "", fmt.Errorf("parse response: %w", err)
	}
	if result.Code != 0 {
		return "", fmt.Errorf("api code=%d", result.Code)
	}
	return result.Bot.OpenID, nil
}

func isBotMentioned(mentions []*larkim.MentionEvent, botOpenID string) bool {
	for _, m := range mentions {

View on GitHub (pinned to 4000b2338a)

Solutions

  1. Inspect the wrapped error for the exact transport cause.
  2. Verify app_id/app_secret and that the correct API domain (.cn vs larksuite) is configured.
  3. Ensure the lark client is created before fetchBotOpenID runs (check startup ordering).
  4. Check host network/proxy access to the Feishu open API.
Defensive patterns

Strategy: fallback

Validate before calling

if p.client == nil {
    return errors.New("feishu: lark client not initialized before fetchBotOpenID")
}

Try / catch

openID, err := p.fetchBotOpenID()
if err != nil {
    slog.Warn("feishu: bot open_id unavailable, continuing without it", "err", err)
    openID = "" // degrade gracefully where open_id is optional
}

Prevention

When it happens

Trigger: p.client.Get(context.Background(), "/open-apis/bot/v3/info", nil, larkcore.AccessTokenTypeTenant) returns err at platform/feishu/feishu.go:3815 — DNS/proxy failure, invalid tenant_access_token acquisition, or nil p.client during startup ordering issues.

Common situations: Platform starting before the lark client is fully initialized; wrong domain (feishu vs Lark) configured so the endpoint doesn't resolve; invalid app credentials; corporate firewall blocking open.feishu.cn.

Understand the failure class

Background: "API request failed": what wrapped HTTP errors from external APIs mean and how to find the real cause — this error's family across 29 libraries.

Related errors


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