larksuite/cli · error

set_reply_to requires addresses

Error message

set_reply_to requires addresses

What it means

Thrown by PatchOp.Validate() in shortcuts/mail/draft/model.go:289 when a set_reply_to op is given an empty Addresses array. Setting Reply-To replaces the whole list, so at least one address is required; use clear_reply_to if the goal is to remove Reply-To entirely.

Source

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

	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")
		}
		if strings.ContainsAny(op.Name, ":\r\n") {
			return fmt.Errorf("set_header: header name must not contain ':', CR, or LF")
		}
		if strings.ContainsAny(op.Value, "\r\n") {

View on GitHub (pinned to 7fd6ef3c07)

Solutions

  1. Add at least one entry to the addresses array of the set_reply_to op.
  2. If the intent is to remove Reply-To, use the clear_reply_to op, which validates as a no-op.
  3. Guard the slice length before constructing the op if it may be empty.

Example fix

// before
{"op":"set_reply_to","addresses":[]}

// after
{"op":"set_reply_to","addresses":[{"address":"support@example.com"}]}
// or to remove Reply-To:
{"op":"clear_reply_to"}
Defensive patterns

Strategy: validation

Validate before calling

if len(op.Addresses) == 0 {
    return fmt.Errorf("set_reply_to needs at least one address")
}

Prevention

When it happens

Trigger: {"op":"set_reply_to","addresses":[]} or op built with Addresses left nil; clearing the slice programmatically before calling Validate.

Common situations: Code paths that build a shared addresses slice and pass it empty; attempting to unset Reply-To with set_reply_to instead of clear_reply_to; JSON produced by serializing a struct whose slice was never appended to (omitempty drops the key, yielding an empty/nil slice).

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/350d14eadeeaeeca. Report an issue: GitHub.