Tencent/WeKnora · error
a message can use at most %d attachments
Error message
a message can use at most %d attachments
What it means
ResolveForPrompt enforces types.MaxTemporaryAttachmentsPerMessage as a hard cap on how many temporary documents may be attached to a single chat message. Exceeding the cap aborts before any document lookup.
Source
Thrown at internal/application/service/temporary_document.go:600
out = append(out, ref.ImageData)
if len(out) >= limit {
break
}
}
return out
}
// approxTextContentRunes counts the runes of real text in markdown, ignoring
// image references, so scanned/image-only documents register as low-text.
func approxTextContentRunes(md string) int {
stripped := markdownImagePattern.ReplaceAllString(md, "")
return len([]rune(strings.TrimSpace(stripped)))
}
func (s *temporaryDocumentService) ResolveForPrompt(ctx context.Context, tenantID uint64, sessionID string, documentIDs []string, query string) (*types.TemporaryDocumentPromptResult, error) {
result := &types.TemporaryDocumentPromptResult{}
if len(documentIDs) > types.MaxTemporaryAttachmentsPerMessage {
return nil, fmt.Errorf("a message can use at most %d attachments", types.MaxTemporaryAttachmentsPerMessage)
}
perDocumentBudget := temporaryDocumentPromptBudget
if len(documentIDs) > 0 {
perDocumentBudget = temporaryDocumentPromptBudget / len(documentIDs)
}
seen := make(map[string]struct{}, len(documentIDs))
for _, documentID := range documentIDs {
if _, duplicate := seen[documentID]; duplicate {
continue
}
seen[documentID] = struct{}{}
document, err := s.repo.GetScoped(ctx, tenantID, sessionID, documentID)
if err != nil {
return nil, err
}
if document == nil {
return nil, fmt.Errorf("attachment %s was not found in this session", documentID)
}View on GitHub (pinned to 988cbb0330)
Solutions
- Limit the attachments selected to MaxTemporaryAttachmentsPerMessage before sending
- Update the client UI to enforce the same cap at selection time
- Split the content across multiple messages if more attachments are needed
- Raise MaxTemporaryAttachmentsPerMessage consciously if the cap is genuinely too low
Example fix
// before
if len(documentIDs) > MaxTemporaryAttachmentsPerMessage { ... }
// after
if len(documentIDs) > MaxTemporaryAttachmentsPerMessage {
documentIDs = documentIDs[:MaxTemporaryAttachmentsPerMessage]
} Defensive patterns
Strategy: validation
Validate before calling
if len(documentIDs) > types.MaxTemporaryAttachmentsPerMessage {
return errors.New("too many attachments")
} Prevention
- Enforce the attachment cap in the UI at selection time
- Never send unchecked documentIDs arrays from API clients
When it happens
Trigger: Calling ResolveForPrompt (via the chat/message send path) with a documentIDs slice longer than MaxTemporaryAttachmentsPerMessage.
Common situations: Client allows unlimited attachment selection in the UI; API consumer sends a large documentIDs array directly; batch message built from prior session references.
Related errors
- attachment exceeds the %d MiB limit
- attachment has no file extension
- invite code has expired
- join request not found
- failed to retrieve: %s
AI-assisted analysis of Tencent/WeKnora@988cbb0330 (2026-09-02).
Data as JSON: /api/errors/ea57273b6ac21bcc.
Report an issue: GitHub.