chenhg5/cc-connect · error

tuitui: channel id is required

Error message

tuitui: channel id is required

What it means

SendChannelPost requires a non-empty channel ID because the TuiTui API needs a destination chat/channel. The value is trimmed and validated first; an empty or whitespace-only ID aborts before any network call. This is a fail-fast input validation error.

Source

Thrown at platform/tuitui/tuitui.go:203

	p.stopping = true
	if p.cancel != nil {
		p.cancel()
	}
	return nil
}

func (p *Platform) Reply(ctx context.Context, replyCtx any, content string) error {
	return p.sendText(ctx, replyCtx, content)
}

func (p *Platform) Send(ctx context.Context, replyCtx any, content string) error {
	return p.sendText(ctx, replyCtx, content)
}

func (p *Platform) SendChannelPost(ctx context.Context, channelID, markdown, parentID string) error {
	channelID = strings.TrimSpace(channelID)
	if channelID == "" {
		return fmt.Errorf("tuitui: channel id is required")
	}
	if strings.TrimSpace(markdown) == "" {
		return fmt.Errorf("tuitui: markdown is required")
	}

	chatID := channelID
	if guessChatType(channelID) == chatTypeChannel {
		if parentID = strings.TrimSpace(parentID); parentID != "" {
			target := teamsParseChatID(channelID)
			chatID = teamsBuildChatID(target["team_id"], target["channel_id"], parentID)
		}
	} else {
		info, err := p.getChannelInfo(ctx, channelID)
		if err != nil {
			return err
		}
		teamID := stringFromAny(info["team_id"])
		if teamID == "" {

View on GitHub (pinned to 4000b2338a)

Solutions

  1. Pass the actual TuiTui channel/chat ID (e.g. from the incoming message's reply context) as channelID.
  2. Trim and check the ID at the call site before invoking SendChannelPost.
  3. Fix the data source that produced an empty channel ID (config value, database field, or parsed key).

Example fix

// before
err := p.SendChannelPost(ctx, channel.ID, md, "") // channel.ID == ""
// after
if strings.TrimSpace(channel.ID) == "" {
    return fmt.Errorf("no channel id for post")
}
err := p.SendChannelPost(ctx, channel.ID, md, "")
Defensive patterns

Strategy: validation

Validate before calling

if strings.TrimSpace(channelID) == "" {
    return fmt.Errorf("cannot post: channel id is empty")
}

Type guard

func hasChannelID(id string) bool { return strings.TrimSpace(id) != "" }

Try / catch

if err := p.SendChannelPost(ctx, chID, md, parent); err != nil && strings.Contains(err.Error(), "channel id is required") {
    log.Warn("skipping post: missing channel id")
}

Prevention

When it happens

Trigger: Calling SendChannelPost(ctx, "", markdown, parentID) or with a whitespace-only string (e.g. " ") as channelID.

Common situations: An upstream message record missing a channel identifier; a variable populated from an empty config field or unfound team/channel mapping passed straight through; splitting a session key that yielded no chat ID.

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


AI-assisted analysis of chenhg5/cc-connect@4000b2338a (2026-09-06). Data as JSON: /api/errors/b3cba007e93060e5. Report an issue: GitHub.