chenhg5/cc-connect · error
tuitui: team_id is required for channel history
Error message
tuitui: team_id is required for channel history
What it means
Channel history fetching requires a team_id to scope the query, and it could not be determined. fetchChannelHistory first tries the caller-supplied team ID or, failing that, derives it from the channel info API (channel's team_id field); if both are empty the request cannot proceed and is rejected.
Source
Thrown at platform/tuitui/history.go:105
parsed := map[string]string{}
if strings.HasPrefix(chatID, "teams_") {
parsed = teamsParseChatID(chatID)
} else {
parsed["channel_id"] = chatID
}
channelID := firstNonEmpty(parsed["channel_id"], chatID)
teamID := parsed["team_id"]
subject := ""
if teamID == "" {
info, err := p.getChannelInfo(ctx, channelID)
if err != nil {
return nil, err
}
teamID = stringFromAny(info["team_id"])
subject = stringFromAny(info["name"])
}
if teamID == "" {
return nil, fmt.Errorf("tuitui: team_id is required for channel history")
}
limit := opts.Limit
if limit <= 0 {
limit = 20
}
limit = minInt(100, maxInt(1, limit))
order := "asc"
if opts.OrderAsc != nil && !*opts.OrderAsc {
order = "desc"
}
payload := map[string]any{
"channel_id": channelID,
"team_id": teamID,
"size": limit,
"sort_type": "reply",
"order": order,
}
if opts.RelativeTime != "" {View on GitHub (pinned to 4000b2338a)
Solutions
- Ensure the bot has read access to the channel so channel info returns team_id.
- Verify the channel_id is correct by fetching channel info first and inspecting the payload.
- Pass/derive team_id explicitly in the caller if the channel-info endpoint no longer returns it.
- Log the raw channel-info JSON to check the field name is still "team_id".
Example fix
// before
res, err := p.FetchHistory(ctx, channelID, "channel", HistoryOptions{})
// after
res, err := p.FetchHistory(ctx, channelID, "channel", HistoryOptions{TeamID: knownTeamID}) Defensive patterns
Strategy: validation
Validate before calling
info, err := p.getChannelInfo(ctx, channelID)
if err != nil { return err }
teamID := stringFromAny(info["team_id"])
if teamID == "" { return fmt.Errorf("cannot resolve team_id for channel %s", channelID) } Type guard
func channelInfoHasTeam(info map[string]any) bool {
return info != nil && stringFromAny(info["team_id"]) != ""
} Try / catch
res, err := p.FetchHistory(ctx, channelID, "channel", opts)
if err != nil && strings.Contains(err.Error(), "team_id is required") {
slog.Warn("channel team_id unavailable; check bot channel access", "channel", channelID)
} Prevention
- Confirm bot read access to the channel before history calls
- Cache team_id from a known-good channel info response
- Pass team_id explicitly when your integration already knows it
- Log raw channel-info payloads when upgrading to catch API shape changes
When it happens
Trigger: Calling FetchHistory with chatType="channel" for a channel whose /robot/teams/channel/info response lacks team_id (info nil or field absent), and no team_id was provided in options.
Common situations: Bot lacks permission to read the channel's metadata so info comes back empty; channel ID mistyped pointing to a nonexistent channel; upstream API changed the info payload shape (e.g. renamed field) breaking stringFromAny extraction.
Understand the failure class
Background: "missing required argument" and "the following required arguments were not provided": what required-argument errors mean and how to fix them — this error's family across 20 libraries.
Related errors
- tuitui: chat id is required
- tuitui: invalid chat type %q
- tuitui: channel history errcode=%d errmsg=%s
- tuitui: channel info errcode=%d errmsg=%s
- tuitui: invalid chat type %q
AI-assisted analysis of chenhg5/cc-connect@4000b2338a (2026-09-06).
Data as JSON: /api/errors/6aa7ec206439920b.
Report an issue: GitHub.