chenhg5/cc-connect · error

slack: invalid reply context type %T

Error message

slack: invalid reply context type %T

What it means

Type-assertion guard in Slack Reply: rctx is not the platform's internal replyContext struct, indicating the reply context did not originate from Slack's message handler (nil, wrong platform, or corrupted value).

Source

Thrown at platform/slack/slack.go:454

// For DM messages (channel_type=im) that are not in an Assistant thread:
// return empty so replies go top-level (natural 1-on-1 conversation).
func assistantOrThreadTS(ev *slackevents.MessageEvent) string {
	if ev.ThreadTimeStamp != "" {
		// Already in a thread (Assistant Chat tab or regular thread reply).
		return ev.ThreadTimeStamp
	}
	// For non-DM channels, thread under the user's message.
	if ev.ChannelType != "im" {
		return ev.TimeStamp
	}
	// DM top-level: top-level reply is natural.
	return ""
}

func (p *Platform) Reply(ctx context.Context, rctx any, content string) error {
	rc, ok := rctx.(replyContext)
	if !ok {
		return fmt.Errorf("slack: invalid reply context type %T", rctx)
	}

	opts := []slack.MsgOption{
		slack.MsgOptionText(core.MarkdownToSlackMrkdwn(content), false),
	}
	if rc.timestamp != "" {
		opts = append(opts, slack.MsgOptionPostMessageParameters(slack.PostMessageParameters{ThreadTimestamp: rc.timestamp}))
	}

	_, _, err := p.client.PostMessageContext(ctx, rc.channel, opts...)
	if err != nil {
		return fmt.Errorf("slack: send: %w", err)
	}
	return nil
}

// Send sends a new message (or threaded reply if rctx has timestamp).
// Patched 2026-05-03: use thread_ts when present so replies in Slack Assistant

View on GitHub (pinned to 4000b2338a)

Solutions

  1. Pass reply contexts produced by the Slack platform itself
Defensive patterns

Strategy: type-guard

When it happens

Trigger: Thrown at platform/slack/slack.go:454 when the library encounters an invalid state.

Common situations: See trigger scenarios.


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