larksuite/cli · error
recipient address is empty
Error message
recipient address is empty
What it means
setRecipients validates every Address in the list being assigned to a to/cc/bcc field. If any entry has an Address value that is empty or whitespace-only, the entire patch op is rejected because a header entry without an address cannot be serialized. Note the operation is all-or-nothing: one bad entry blocks the whole set.
Source
Thrown at shortcuts/mail/draft/patch.go:166
}
func ensureHeaderEditable(name string, options PatchOptions) error {
if protectedHeaders[strings.ToLower(strings.TrimSpace(name))] && !options.AllowProtectedHeaderEdits {
return fmt.Errorf("header %q is protected; rerun with allow_protected_header_edits", name)
}
return nil
}
func setRecipients(snapshot *DraftSnapshot, field string, addrs []Address) error {
field = strings.ToLower(strings.TrimSpace(field))
if !isRecipientField(field) {
return fmt.Errorf("recipient field must be one of to/cc/bcc")
}
normalized := make([]Address, 0, len(addrs))
seen := map[string]bool{}
for _, addr := range addrs {
if strings.TrimSpace(addr.Address) == "" {
return fmt.Errorf("recipient address is empty")
}
key := strings.ToLower(strings.TrimSpace(addr.Address))
if seen[key] {
continue
}
seen[key] = true
normalized = append(normalized, Address{
Name: addr.Name,
Address: strings.TrimSpace(addr.Address),
})
}
_, headerName := recipientField(snapshot, field)
setRecipientField(snapshot, headerName, normalized)
return nil
}
func addRecipient(snapshot *DraftSnapshot, field string, addr Address) error {
if strings.TrimSpace(addr.Address) == "" {View on GitHub (pinned to 7fd6ef3c07)
Solutions
- Filter out entries with empty/whitespace Address values before calling set_recipients
- Parse display-name-style input so Address is extracted (e.g. 'Bob <bob@x.com>' -> bob@x.com) instead of storing only the name
- If the whole field should be cleared, pass an empty list rather than a list containing a blank address
Example fix
// before
setRecipients(snap, "to", []Address{{Name: "Bob", Address: ""}})
// after
addrs := []Address{{Name: "Bob", Address: ""}}
var valid []Address
for _, a := range addrs {
if strings.TrimSpace(a.Address) != "" {
valid = append(valid, a)
}
}
setRecipients(snap, "to", valid) Defensive patterns
Strategy: validation
Validate before calling
func validRecipients(addrs []Address) bool {
for _, a := range addrs {
if strings.TrimSpace(a.Address) == "" {
return false
}
}
return true
} Type guard
func hasAddress(a Address) bool { return strings.TrimSpace(a.Address) != "" } Prevention
- Filter blank entries from recipient lists before building patch ops
- Parse 'Name <addr>' strings so Address is always populated
- Treat an empty field as an empty list, never a list with one blank entry
When it happens
Trigger: Calling set_recipients (via applyOp) or buildDraftEditPatch with an Address whose Address field is "" or only spaces, e.g. parsing "Name <" or splitting an address list that ends with a separator.
Common situations: Building recipient lists from user input or CSV rows where a trailing comma or blank row yields an empty address; programmatic name-only entries (Name set, Address empty); template placeholders never filled in.
Understand the failure class
Background: "must not be empty", "cannot be empty" — required-field validation errors across open-source libraries — this error's family across 41 libraries.
Related errors
- recipient field must be one of to/cc/bcc
- draft main body is text/html and text/plain is only its summ
- unsupported body kind %q
- set_calendar: event_start must be a valid ISO 8601 timestamp
- set_calendar: event_end must be a valid ISO 8601 timestamp
AI-assisted analysis of larksuite/cli@7fd6ef3c07 (2026-09-04).
Data as JSON: /api/errors/99b51aa37a3f5001.
Report an issue: GitHub.