{"record":{"id":"b88cade567bd6b9b","repo":"Tencent/WeKnora","slug":"platform-s-does-not-support-attachment-download","errorCode":null,"errorMessage":"platform %s does not support attachment download","messagePattern":"platform (.+?) does not support attachment download","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/im/service.go","lineNumber":614,"sourceCode":"\ntype imDownloadedAttachment struct {\n\tfileName string\n\tcontent  []byte\n}\n\n// prepareIMAttachments downloads an IM attachment and exposes its parsed text\n// (and, for images, a bounded data URI) to the QA pipeline. This is separate\n// from the optional background knowledge-base save.\nfunc (s *Service) prepareIMAttachments(ctx context.Context, msg *IncomingMessage, adapter Adapter) (types.MessageAttachments, []string, *imDownloadedAttachment, error) {\n\tif msg.MessageType != MessageTypeFile && msg.MessageType != MessageTypeImage {\n\t\treturn nil, nil, nil, nil\n\t}\n\tif msg.FileSize > maxIMAttachmentBytes {\n\t\treturn nil, nil, nil, fmt.Errorf(\"attachment exceeds the %d MiB limit\", maxIMAttachmentBytes>>20)\n\t}\n\tdownloader, ok := adapter.(FileDownloader)\n\tif !ok {\n\t\treturn nil, nil, nil, fmt.Errorf(\"platform %s does not support attachment download\", msg.Platform)\n\t}\n\tattachmentCtx, cancel := context.WithTimeout(ctx, imAttachmentReadTimeout)\n\tdefer cancel()\n\treader, fileName, err := downloader.DownloadFile(attachmentCtx, msg)\n\tif err != nil {\n\t\treturn nil, nil, nil, err\n\t}\n\tdefer reader.Close()\n\tcontent, err := io.ReadAll(io.LimitReader(reader, maxIMAttachmentBytes+1))\n\tif err != nil {\n\t\treturn nil, nil, nil, err\n\t}\n\tif len(content) > maxIMAttachmentBytes {\n\t\treturn nil, nil, nil, fmt.Errorf(\"attachment exceeds the %d MiB limit\", maxIMAttachmentBytes>>20)\n\t}\n\tif fileName == \"\" {\n\t\tfileName = msg.FileName\n\t}","sourceCodeStart":596,"sourceCodeEnd":632,"githubUrl":"https://github.com/Tencent/WeKnora/blob/988cbb03305e055d8ebb7d46d9ac6cc0803cd074/internal/im/service.go#L596-L632","documentation":"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.","triggerScenarios":"Sending a file or image message through a channel whose platform adapter was not built with download support (adapter.(FileDownloader) type assertion fails).","commonSituations":"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.","solutions":["Use a platform adapter that implements FileDownloader for file/image channels","Implement DownloadFile on your custom adapter type","Route attachment-heavy conversations to a supported platform (e.g. telegram, qqbot)"],"exampleFix":"// before\nfunc (a *myAdapter) Start(ctx context.Context) error {...} // no DownloadFile\n// after\nfunc (a *myAdapter) DownloadFile(ctx context.Context, msg *im.IncomingMessage) (io.ReadCloser, string, error) {...}","handlingStrategy":"type-guard","validationCode":"if _, ok := adapter.(im.FileDownloader); !ok {\n    // platform can't handle attachments; skip or reply with guidance\n}","typeGuard":"func supportsAttachmentDownload(a im.Adapter) bool {\n    _, ok := a.(im.FileDownloader)\n    return ok\n}","tryCatchPattern":null,"preventionTips":["Verify the adapter implements FileDownloader before enabling file/image message types","Keep custom adapters feature-complete or restrict enabled message types per platform"],"tags":["attachments","adapter","capability-missing"],"backgroundTag":"adapter-capability-not-supported","analyzedSha":"988cbb03305e055d8ebb7d46d9ac6cc0803cd074","analyzedAt":"2026-09-02T14:41:08.344Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}