larksuite/cli · error

invalid patch op #%d: %w

Error message

invalid patch op #%d: %w

What it means

Wrapper in Patch.Validate: the op at the given 1-based index failed its own validation; the underlying op error is preserved as the cause.

Source

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

	CalendarICS []byte `json:"-"`
}

// SignatureImage holds pre-downloaded image data for signature inline images.
// Populated by the shortcut layer, consumed by the patch layer.
type SignatureImage struct {
	CID         string
	ContentType string
	FileName    string
	Data        []byte
}

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")
		}

View on GitHub (pinned to 7fd6ef3c07)

Solutions

  1. Fix the flagged op per the wrapped error
Defensive patterns

Strategy: validation

When it happens

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