larksuite/cli · error

set_subject requires value

Error message

set_subject requires value

What it means

Guard in PatchOp.Validate: a set_subject op has an empty or whitespace-only value; a subject replacement requires non-empty text.

Source

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

}

func (p Patch) Validate() error {
	if len(p.Ops) == 0 {
		return fmt.Errorf("patch ops is required")
	}
	for i, op := range p.Ops {
		if err := op.Validate(); err != nil {
			return fmt.Errorf("invalid patch op #%d: %w", i+1, err)
		}
	}
	return nil
}

func (op PatchOp) Validate() error {
	switch op.Op {
	case "set_subject":
		if strings.TrimSpace(op.Value) == "" {
			return fmt.Errorf("set_subject requires value")
		}
		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) == "" {

View on GitHub (pinned to 7fd6ef3c07)

Solutions

  1. Provide a non-empty subject
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at shortcuts/mail/draft/model.go:266 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/f19e5434aa2d6f1d. Report an issue: GitHub.