larksuite/cli · error
fetch bot info: %w
Error message
fetch bot info: %w
What it means
Wraps any transport-level error from DoAPIAsBot when calling /open-apis/bot/v3/info. The underlying cause (network error, auth failure, request build error) is preserved via %w. It indicates the bot info HTTP request itself failed before a response could be evaluated.
Source
Thrown at shortcuts/common/runner.go:168
return nil, errs.NewValidationError(errs.SubtypeFailedPrecondition, "BotInfo is unavailable during dry-run")
}
if ctx.botInfoFunc == nil {
return nil, fmt.Errorf("BotInfo not available (runtime context not fully initialized)")
}
return ctx.botInfoFunc()
}
// fetchBotInfo calls /bot/v3/info using bot identity and parses the response.
func (ctx *RuntimeContext) fetchBotInfo() (*BotInfo, error) {
if !ctx.Config.CanBot() {
return nil, fmt.Errorf("fetch bot info: bot identity is not available in current credential context")
}
resp, err := ctx.DoAPIAsBot(&larkcore.ApiReq{
HttpMethod: http.MethodGet,
ApiPath: "/open-apis/bot/v3/info",
})
if err != nil {
return nil, fmt.Errorf("fetch bot info: %w", err)
}
if resp.StatusCode >= 400 {
return nil, fmt.Errorf("fetch bot info: HTTP %d", resp.StatusCode)
}
// /open-apis/bot/v3/info returns `{code, msg, bot: {...}}` — the bot
// payload is under "bot", not "data" as the newer Lark API convention.
var envelope struct {
Code int `json:"code"`
Msg string `json:"msg"`
Data struct {
OpenID string `json:"open_id"`
AppName string `json:"app_name"`
} `json:"bot"`
}
if err := json.Unmarshal(resp.RawBody, &envelope); err != nil {
return nil, fmt.Errorf("fetch bot info: unmarshal: %w", err)
}
if envelope.Code != 0 {View on GitHub (pinned to 7fd6ef3c07)
Solutions
- Inspect the wrapped cause (%w) for the transport failure and fix it (network, proxy, credentials)
- Verify connectivity to the Lark/Feishu gateway with a simpler command (e.g. an auth or whoami call)
- Re-authenticate or refresh the bot credentials if the cause indicates auth failure
Defensive patterns
Strategy: try-catch
Try / catch
info, err := ctx.BotInfo()
if err != nil {
if strings.Contains(err.Error(), "fetch bot info:") && !strings.Contains(err.Error(), "HTTP") {
// transport error: inspect errors.Unwrap(err) for net/http cause
return fmt.Errorf("cannot reach Lark API: %w", err)
}
return err
} Prevention
- Check network/proxy reachability to open.feishu.cn before automation runs
- Refresh credentials regularly to avoid auth-layer transport failures
- Log the unwrapped cause chain for diagnosis
When it happens
Trigger: ctx.DoAPIAsBot returns an error during BotInfo(): unreachable network, invalid/expired bot token rejected at request layer, proxy/TLS failures, or request construction errors.
Common situations: Offline or firewalled environments; expired app credentials; DNS or corporate proxy issues when the CLI calls open.feishu.cn.
Understand the failure class
Background: 'Something went wrong' / 'Request failed (500)' / 'HTTP error! status: 404' — what failed HTTP requests actually mean and how to find the real cause — this error's family across 28 libraries.
Related errors
- Device authorization failed: read body: %v
- failed to read response body in security transport: %w
- index request failed: %s
- fetch bot info: HTTP %d
- annotated_csv did not parse into the rows the server reporte
AI-assisted analysis of larksuite/cli@7fd6ef3c07 (2026-09-04).
Data as JSON: /api/errors/261308287384ea95.
Report an issue: GitHub.