chenhg5/cc-connect · error
tuitui: channel history errcode=%d errmsg=%s
Error message
tuitui: channel history errcode=%d errmsg=%s
What it means
The TuiTui channel topic/post list API (/robot/teams/post/topic/list) returned a non-zero errcode, meaning the backend rejected the history query despite an HTTP-level success. The backend errmsg is surfaced verbatim so the specific cause can be diagnosed.
Source
Thrown at platform/tuitui/history.go:168
} else {
payload["from_timestamp"] = opts.Cursor
}
}
}
var out struct {
ErrCode int `json:"errcode"`
ErrMsg string `json:"errmsg"`
Time any `json:"time"`
Datas struct {
PostList []map[string]any `json:"post_list"`
} `json:"datas"`
}
if err := p.postJSON(ctx, "/robot/teams/post/topic/list", payload, &out); err != nil {
return nil, err
}
if out.ErrCode != 0 {
return nil, fmt.Errorf("tuitui: channel history errcode=%d errmsg=%s", out.ErrCode, out.ErrMsg)
}
cursor := ""
if len(out.Datas.PostList) > 0 {
if topic, _ := out.Datas.PostList[len(out.Datas.PostList)-1]["topic"].(map[string]any); topic != nil {
if n := numberFromAny(topic["last_reply_time"]); n > 0 {
next := int64(n) + 1
if order == "desc" {
next = int64(n) - 1
}
cursor = strconv.FormatInt(next, 10)
}
}
}
return &HistoryResult{
ErrCode: out.ErrCode,
ErrMsg: out.ErrMsg,
Cursor: cursor,
HasMore: len(out.Datas.PostList) >= limit,View on GitHub (pinned to 4000b2338a)
Solutions
- Inspect errmsg for the backend's stated reason and match it to the errcode docs.
- Re-fetch channel info to get a fresh team_id, then retry.
- Verify bot membership and permissions on the target team.
- If transient (backend 5xx-style errcode), retry with backoff.
Example fix
// before
if out.ErrCode != 0 {
return nil, fmt.Errorf("tuitui: channel history errcode=%d errmsg=%s", out.ErrCode, out.ErrMsg)
}
// after
if out.ErrCode != 0 {
if isTransient(out.ErrCode) { return p.fetchChannelHistory(ctx, chatID, opts) }
return nil, fmt.Errorf("tuitui: channel history errcode=%d errmsg=%s", out.ErrCode, out.ErrMsg)
} Defensive patterns
Strategy: retry
Validate before calling
if _, err := p.getChannelInfo(ctx, channelID); err != nil {
return fmt.Errorf("channel unavailable for history: %w", err)
} Try / catch
res, err := p.FetchHistory(ctx, channelID, "channel", opts)
if err != nil {
if retriable(err) { // transient backend errcode
backoff(ctx, func() error { res, err = p.FetchHistory(ctx, channelID, "channel", opts); return err })
}
} Prevention
- Verify bot team membership and permissions first
- Refresh team_id from channel info rather than caching indefinitely
- Treat not-found vs permission errcodes differently (no retry vs fix access)
- Cap retries with backoff to avoid hammering a failing backend
When it happens
Trigger: fetchChannelHistory posts the topic list request and out.ErrCode != 0 — e.g. invalid team_id, bot lacking team permissions, channel archived/deleted, or pagination cursor past the end.
Common situations: Bot not added to the team; team_id derived from a stale channel-info cache; requesting history in a channel whose posts were purged; backend limit/permission changes on the TuiTui side.
Related errors
- tuitui: channel info 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/4d015a651ed53633.
Report an issue: GitHub.