Tencent/WeKnora · error

platform %s does not support attachment download

Error message

platform %s does not support attachment download

What it means

The IM service only prepares attachments when the platform's Adapter implements the FileDownloader interface. If the adapter for msg.Platform does not implement DownloadFile, the message's file/image attachment cannot be fetched and this error is returned.

Source

Thrown at internal/im/service.go:614

type imDownloadedAttachment struct {
	fileName string
	content  []byte
}

// prepareIMAttachments downloads an IM attachment and exposes its parsed text
// (and, for images, a bounded data URI) to the QA pipeline. This is separate
// from the optional background knowledge-base save.
func (s *Service) prepareIMAttachments(ctx context.Context, msg *IncomingMessage, adapter Adapter) (types.MessageAttachments, []string, *imDownloadedAttachment, error) {
	if msg.MessageType != MessageTypeFile && msg.MessageType != MessageTypeImage {
		return nil, nil, nil, nil
	}
	if msg.FileSize > maxIMAttachmentBytes {
		return nil, nil, nil, fmt.Errorf("attachment exceeds the %d MiB limit", maxIMAttachmentBytes>>20)
	}
	downloader, ok := adapter.(FileDownloader)
	if !ok {
		return nil, nil, nil, fmt.Errorf("platform %s does not support attachment download", msg.Platform)
	}
	attachmentCtx, cancel := context.WithTimeout(ctx, imAttachmentReadTimeout)
	defer cancel()
	reader, fileName, err := downloader.DownloadFile(attachmentCtx, msg)
	if err != nil {
		return nil, nil, nil, err
	}
	defer reader.Close()
	content, err := io.ReadAll(io.LimitReader(reader, maxIMAttachmentBytes+1))
	if err != nil {
		return nil, nil, nil, err
	}
	if len(content) > maxIMAttachmentBytes {
		return nil, nil, nil, fmt.Errorf("attachment exceeds the %d MiB limit", maxIMAttachmentBytes>>20)
	}
	if fileName == "" {
		fileName = msg.FileName
	}

View on GitHub (pinned to 988cbb0330)

Solutions

  1. Use a platform adapter that implements FileDownloader for file/image channels
  2. Implement DownloadFile on your custom adapter type
  3. Route attachment-heavy conversations to a supported platform (e.g. telegram, qqbot)

Example fix

// before
func (a *myAdapter) Start(ctx context.Context) error {...} // no DownloadFile
// after
func (a *myAdapter) DownloadFile(ctx context.Context, msg *im.IncomingMessage) (io.ReadCloser, string, error) {...}
Defensive patterns

Strategy: type-guard

Validate before calling

if _, ok := adapter.(im.FileDownloader); !ok {
    // platform can't handle attachments; skip or reply with guidance
}

Type guard

func supportsAttachmentDownload(a im.Adapter) bool {
    _, ok := a.(im.FileDownloader)
    return ok
}

Prevention

When it happens

Trigger: Sending a file or image message through a channel whose platform adapter was not built with download support (adapter.(FileDownloader) type assertion fails).

Common situations: Using a community/custom adapter that handles text only; a platform where the library has not implemented file download yet; registering a custom factory returning a minimal adapter.

Related errors


AI-assisted analysis of Tencent/WeKnora@988cbb0330 (2026-09-02). Data as JSON: /api/errors/b88cade567bd6b9b. Report an issue: GitHub.