larksuite/cli · error

attachment count %d exceeds the limit of %d

Error message

attachment count %d exceeds the limit of %d

What it means

Attachment-limit guard in checkSnapshotAttachmentLimit: adding the new attachment would push the draft past maxAttachmentCount (existing plus new parts).

Source

Thrown at shortcuts/mail/draft/limits.go:58

	var existingBytes int64
	for _, p := range flattenParts(snapshot.Body) {
		if p.IsMultipart() || !isAttachmentOrInline(p) {
			continue
		}
		existingCount++
		existingBytes += int64(len(p.Body))
	}

	totalCount := existingCount
	totalBytes := existingBytes + newFileSize
	if replacedPart != nil {
		totalBytes -= int64(len(replacedPart.Body))
	} else {
		totalCount++
	}

	if totalCount > maxAttachmentCount {
		return fmt.Errorf("attachment count %d exceeds the limit of %d", totalCount, maxAttachmentCount)
	}
	if totalBytes > maxAttachmentBytes {
		return fmt.Errorf("total attachment size %.1f MB exceeds the 25 MB limit",
			float64(totalBytes)/1024/1024)
	}
	return nil
}

View on GitHub (pinned to 7fd6ef3c07)

Solutions

  1. Remove some attachments first, or split the mail into multiple messages
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at shortcuts/mail/draft/limits.go:58 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of larksuite/cli@7fd6ef3c07 (2026-09-04). Data as JSON: /api/errors/ee131b22d9299287. Report an issue: GitHub.