larksuite/cli · error

%s requires address

Error message

%s requires address

What it means

Thrown by PatchOp.Validate() in shortcuts/mail/draft/model.go:285 for add_recipient or remove_recipient ops whose op.Address is empty or whitespace-only. The message interpolates the op name (e.g. "add_recipient requires address"). These ops mutate exactly one recipient, so an address is mandatory.

Source

Thrown at shortcuts/mail/draft/model.go:285

		}
		if strings.ContainsAny(op.Value, "\r\n") {
			return fmt.Errorf("set_subject: value must not contain CR or LF")
		}
	case "set_recipients":
		if !isRecipientField(op.Field) {
			return fmt.Errorf("recipient field must be one of to/cc/bcc")
		}
		for _, addr := range op.Addresses {
			if strings.TrimSpace(addr.Address) == "" {
				return fmt.Errorf("set_recipients requires non-empty addresses")
			}
		}
	case "add_recipient", "remove_recipient":
		if !isRecipientField(op.Field) {
			return fmt.Errorf("recipient field must be one of to/cc/bcc")
		}
		if strings.TrimSpace(op.Address) == "" {
			return fmt.Errorf("%s requires address", op.Op)
		}
	case "set_reply_to":
		if len(op.Addresses) == 0 {
			return fmt.Errorf("set_reply_to requires addresses")
		}
	case "clear_reply_to":
	case "set_body", "set_reply_body":
	case "replace_body", "append_body":
		if !isBodyKind(op.BodyKind) {
			return fmt.Errorf("body_kind must be text/plain or text/html")
		}
		if op.Selector != "" && op.Selector != "primary" {
			return fmt.Errorf("selector must be primary")
		}
	case "set_header":
		if strings.TrimSpace(op.Name) == "" {
			return fmt.Errorf("set_header requires name")
		}

View on GitHub (pinned to 7fd6ef3c07)

Solutions

  1. Provide the full address string in op.Address for the add_recipient/remove_recipient op.
  2. Verify the variable feeding Address is populated before constructing the op.
  3. To clear all recipients of a field, use set_recipients with an empty addresses array context per your workflow instead of a blank remove_recipient.

Example fix

// before
{"op":"remove_recipient","field":"to","address":""}

// after
{"op":"remove_recipient","field":"to","address":"old@example.com"}
Defensive patterns

Strategy: validation

Validate before calling

if strings.TrimSpace(op.Address) == "" {
    return fmt.Errorf("%s needs an address", op.Op)
}

Prevention

When it happens

Trigger: {"op":"add_recipient","field":"to"} with no address key, address:"", or address:" "; building the op from a variable that was empty; JSON where address was omitted because it was empty with omitempty semantics.

Common situations: Variables holding the recipient left unset after failed parsing; removing a recipient by passing an empty address hoping it matches all; template engines substituting an empty string for a missing placeholder.

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


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