chenhg5/cc-connect · error
tuitui: channel info errcode=%d errmsg=%s
Error message
tuitui: channel info errcode=%d errmsg=%s
What it means
The TuiTui channel info API (/robot/teams/channel/info) returned a non-zero errcode, so the channel's metadata (team_id, name) could not be retrieved. This function underpins both channel history fetching and SendChannelPost, so both fail when it errors.
Source
Thrown at platform/tuitui/history.go:254
}
out = append(out, item)
}
return out
}
func (p *Platform) getChannelInfo(ctx context.Context, channelID string) (map[string]any, error) {
var out struct {
ErrCode int `json:"errcode"`
ErrMsg string `json:"errmsg"`
Datas struct {
Info map[string]any `json:"info"`
} `json:"datas"`
}
if err := p.postJSON(ctx, "/robot/teams/channel/info", map[string]any{"channel_id": channelID}, &out); err != nil {
return nil, err
}
if out.ErrCode != 0 {
return nil, fmt.Errorf("tuitui: channel info errcode=%d errmsg=%s", out.ErrCode, out.ErrMsg)
}
return out.Datas.Info, nil
}
func formatPostThreads(posts []map[string]any) []string {
threads := make([]string, 0, len(posts))
for _, postThread := range posts {
var items []map[string]any
if topic, _ := postThread["topic"].(map[string]any); topic != nil {
items = append(items, topic)
}
if replies, _ := postThread["reply_list"].([]any); len(replies) > 0 {
for i := len(replies) - 1; i >= 0; i-- {
if reply, _ := replies[i].(map[string]any); reply != nil {
items = append(items, reply)
}
}
}View on GitHub (pinned to 4000b2338a)
Solutions
- Read errmsg to identify the backend reason (not-found vs permission vs auth).
- Verify the channel_id exists and the bot has access to that channel/team.
- Refresh the bot token if the errcode indicates auth failure.
- For SendChannelPost failures, check the bot was invited to the channel before posting.
Example fix
// before
if out.ErrCode != 0 {
return nil, fmt.Errorf("tuitui: channel info errcode=%d errmsg=%s", out.ErrCode, out.ErrMsg)
}
// after
if out.ErrCode == errChannelNotFound {
return nil, fmt.Errorf("tuitui: channel %s not found or no access: check bot membership", channelID)
}
return nil, fmt.Errorf("tuitui: channel info errcode=%d errmsg=%s", out.ErrCode, out.ErrMsg) Defensive patterns
Strategy: try-catch
Validate before calling
if channelID == "" { return fmt.Errorf("channel id required") }
// ensure bot invited to channel/team before calling SendChannelPost Type guard
func (p *Platform) channelAccessible(ctx context.Context, id string) bool {
_, err := p.getChannelInfo(ctx, id)
return err == nil
} Try / catch
info, err := p.getChannelInfo(ctx, channelID)
if err != nil {
var apiErr *TuiTuiAPIError
if errors.As(err, &apiErr) && apiErr.IsAuth() {
if rerr := p.refreshToken(ctx); rerr == nil {
info, err = p.getChannelInfo(ctx, channelID)
}
}
if err != nil { return fmt.Errorf("cannot access channel %s: %w", channelID, err) }
} Prevention
- Validate channel IDs at config load with a getChannelInfo probe
- Invite the bot to the team/channel before programmatic posting
- Refresh tokens proactively before long-running operations
- Map errcodes to user-actionable messages (not-found, permission, auth)
When it happens
Trigger: getChannelInfo called by fetchChannelHistory or SendChannelPost where the response body carries out.ErrCode != 0 — typically channel_id not found, bot lacks channel access, or an invalid/expired token.
Common situations: Channel deleted or ID mistyped; bot removed from the channel/team; token refresh lapse; sending a post to a channel the bot was never invited to.
Related errors
- tuitui: channel history errcode=%d errmsg=%s
- slack: resolve channel name for %s: %w
- tuitui: history errcode=%d errmsg=%s
- tuitui: team_id is required for channel history
- errcode=%d errmsg=%s
AI-assisted analysis of chenhg5/cc-connect@4000b2338a (2026-09-06).
Data as JSON: /api/errors/10db54ffb8ebcdd9.
Report an issue: GitHub.