{"record":{"id":"261308287384ea95","repo":"larksuite/cli","slug":"fetch-bot-info-w","errorCode":null,"errorMessage":"fetch bot info: %w","messagePattern":"fetch bot info: %w","errorType":"error_code","errorClass":null,"httpStatus":null,"severity":"error","filePath":"shortcuts/common/runner.go","lineNumber":168,"sourceCode":"\t\treturn nil, errs.NewValidationError(errs.SubtypeFailedPrecondition, \"BotInfo is unavailable during dry-run\")\n\t}\n\tif ctx.botInfoFunc == nil {\n\t\treturn nil, fmt.Errorf(\"BotInfo not available (runtime context not fully initialized)\")\n\t}\n\treturn ctx.botInfoFunc()\n}\n\n// fetchBotInfo calls /bot/v3/info using bot identity and parses the response.\nfunc (ctx *RuntimeContext) fetchBotInfo() (*BotInfo, error) {\n\tif !ctx.Config.CanBot() {\n\t\treturn nil, fmt.Errorf(\"fetch bot info: bot identity is not available in current credential context\")\n\t}\n\tresp, err := ctx.DoAPIAsBot(&larkcore.ApiReq{\n\t\tHttpMethod: http.MethodGet,\n\t\tApiPath:    \"/open-apis/bot/v3/info\",\n\t})\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"fetch bot info: %w\", err)\n\t}\n\tif resp.StatusCode >= 400 {\n\t\treturn nil, fmt.Errorf(\"fetch bot info: HTTP %d\", resp.StatusCode)\n\t}\n\t// /open-apis/bot/v3/info returns `{code, msg, bot: {...}}` — the bot\n\t// payload is under \"bot\", not \"data\" as the newer Lark API convention.\n\tvar envelope struct {\n\t\tCode int    `json:\"code\"`\n\t\tMsg  string `json:\"msg\"`\n\t\tData struct {\n\t\t\tOpenID  string `json:\"open_id\"`\n\t\t\tAppName string `json:\"app_name\"`\n\t\t} `json:\"bot\"`\n\t}\n\tif err := json.Unmarshal(resp.RawBody, &envelope); err != nil {\n\t\treturn nil, fmt.Errorf(\"fetch bot info: unmarshal: %w\", err)\n\t}\n\tif envelope.Code != 0 {","sourceCodeStart":150,"sourceCodeEnd":186,"githubUrl":"https://github.com/larksuite/cli/blob/7fd6ef3c07182257ce776cdc5a614e122d5bd4b3/shortcuts/common/runner.go#L150-L186","documentation":"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.","triggerScenarios":"ctx.DoAPIAsBot returns an error during BotInfo(): unreachable network, invalid/expired bot token rejected at request layer, proxy/TLS failures, or request construction errors.","commonSituations":"Offline or firewalled environments; expired app credentials; DNS or corporate proxy issues when the CLI calls open.feishu.cn.","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"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"info, err := ctx.BotInfo()\nif err != nil {\n\tif strings.Contains(err.Error(), \"fetch bot info:\") && !strings.Contains(err.Error(), \"HTTP\") {\n\t\t// transport error: inspect errors.Unwrap(err) for net/http cause\n\t\treturn fmt.Errorf(\"cannot reach Lark API: %w\", err)\n\t}\n\treturn err\n}","preventionTips":["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"],"tags":["go","network","http","bot-identity"],"backgroundTag":"http-request-failed","analyzedSha":"7fd6ef3c07182257ce776cdc5a614e122d5bd4b3","analyzedAt":"2026-09-04T21:17:44.649Z","contentChangedAt":"2026-09-04T21:17:44.649Z","schemaVersion":2},"datasetVersion":"2026-09-12T02:17:10.037Z"}