larksuite/cli · error

add_inline requires path

Error message

add_inline requires path

What it means

An `add_inline` operation embeds an inline image/file into the draft body and therefore needs both a local file to upload (`path`) and a content ID (`cid`) to reference it from HTML. The validator rejects the op when `path` is missing, empty, or whitespace-only.

Source

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

		}
		if strings.ContainsAny(op.Value, "\r\n") {
			return fmt.Errorf("set_header: header value must not contain CR or LF")
		}
	case "remove_header":
		if strings.TrimSpace(op.Name) == "" {
			return fmt.Errorf("remove_header requires name")
		}
	case "add_attachment":
		if strings.TrimSpace(op.Path) == "" {
			return fmt.Errorf("add_attachment requires path")
		}
	case "remove_attachment":
		if !op.Target.hasAnyKey() {
			return fmt.Errorf("remove_attachment requires target with at least one of part_id, cid, or token")
		}
	case "add_inline":
		if strings.TrimSpace(op.Path) == "" {
			return fmt.Errorf("add_inline requires path")
		}
		if strings.TrimSpace(op.CID) == "" {
			return fmt.Errorf("add_inline requires cid")
		}
	case "replace_inline":
		if !op.Target.hasKey() {
			return fmt.Errorf("replace_inline requires target with at least one of part_id or cid")
		}
		if strings.TrimSpace(op.Path) == "" {
			return fmt.Errorf("replace_inline requires path")
		}
	case "remove_inline":
		if !op.Target.hasKey() {
			return fmt.Errorf("remove_inline requires target with at least one of part_id or cid")
		}
	case "insert_signature":
		if strings.TrimSpace(op.SignatureID) == "" {
			return fmt.Errorf("insert_signature requires signature_id")

View on GitHub (pinned to 7fd6ef3c07)

Solutions

  1. Add a non-empty `path` field to the add_inline operation pointing at the file to embed
  2. Ensure the cid is also set (add_inline requires both path and cid)
  3. Verify the path source (config/env/glob) actually produced a value before building the op

Example fix

// before
{"op":"add_inline","cid":"logo1"}
// after
{"op":"add_inline","cid":"logo1","path":"/tmp/logo.png"}
Defensive patterns

Strategy: validation

Validate before calling

if strings.TrimSpace(op.Path) == "" {
    return fmt.Errorf("add_inline requires path")
}

Type guard

func hasAddInlinePath(op DraftOp) bool { return strings.TrimSpace(op.Path) != "" }

Prevention

When it happens

Trigger: Submitting `{"op":"add_inline","cid":"img1"}` without `path`, or with `path: ""` / whitespace only.

Common situations: Generated op lists where the image file path variable was empty; omitting path because remove_inline/replace_inline targets use cid-based identification and were confused with add_inline requirements.

Understand the failure class

Background: "missing required argument" and "the following required arguments were not provided": what required-argument errors mean and how to fix them — this error's family across 20 libraries.

Related errors


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