chenhg5/cc-connect · error

platform %s: %w

Error message

platform %s: %w

What it means

The engine wraps ErrNotSupported with the platform name when the target platform does not implement the optional ImageSender interface but the send request contains images. Rich media sending is a per-platform capability, not guaranteed by the base Platform interface.

Source

Thrown at core/engine.go:11203

	state, p, replyCtx, err := e.resolveOutboundSessionTarget(sessionKey, len(images) > 0 || len(files) > 0)
	if err != nil {
		return err
	}

	if message == "" && len(images) == 0 && len(files) == 0 {
		return fmt.Errorf("message or attachment is required")
	}
	if (len(images) > 0 || len(files) > 0) && !e.attachmentSendEnabled {
		return ErrAttachmentSendDisabled
	}

	var imageSender ImageSender
	if len(images) > 0 {
		var ok bool
		imageSender, ok = p.(ImageSender)
		if !ok {
			return fmt.Errorf("platform %s: %w", p.Name(), ErrNotSupported)
		}
	}

	var fileSender FileSender
	if len(files) > 0 {
		var ok bool
		fileSender, ok = p.(FileSender)
		if !ok {
			return fmt.Errorf("platform %s: %w", p.Name(), ErrNotSupported)
		}
	}

	if message != "" {
		if err := e.waitOutgoing(p); err != nil {
			return err
		}
		// Use AtMentionSender when @users specified and platform supports it
		if len(opts.AtUsers) > 0 || opts.AtAll {

View on GitHub (pinned to 4000b2338a)

Solutions

  1. Check the target platform implements core.ImageSender before sending images (capability check via type assertion)
  2. Remove image attachments from the request for that platform
  3. Upgrade or fix the platform adapter to implement SendImage / the ImageSender interface

Example fix

// before
engine.SendToSession(key, msg, imgs, nil, "", nil, false) // panics into ErrNotSupported on text-only platform
// after
if _, ok := platform.(core.ImageSender); !ok {
    imgs = nil // or send a download link as text
}
engine.SendToSession(key, msg, imgs, nil, "", nil, false)
Defensive patterns

Strategy: type-guard

Validate before calling

if _, ok := platform.(core.ImageSender); !ok { /* strip images or error early */ }

Type guard

func supportsImages(p core.Platform) bool { _, ok := p.(core.ImageSender); return ok }

Try / catch

if err := engine.SendToSession(...); err != nil {
    var nsErr = core.ErrNotSupported
    if errors.Is(err, nsErr) { log.Warn("platform lacks image support; falling back to text") }
}

Prevention

When it happens

Trigger: Calling the engine send API with len(images)>0 against a platform adapter (e.g. one lacking card/image upload support) whose concrete type does not satisfy core.ImageSender.

Common situations: Switching a bot to a platform that only supports plain text (e.g. a minimal custom adapter, or an older platform plugin predating image support); config pointing a session at a different platform type than the code assumes.

Understand the failure class

Background: UnsupportedOperationException and "is not supported" errors: when a library deliberately refuses a call — this error's family across 30 libraries.

Related errors


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