larksuite/cli · error
add_inline requires cid
Error message
add_inline requires cid
What it means
An `add_inline` operation requires a `cid` (Content-ID) in addition to `path`, because the embedded file must be referenced from the HTML body via `cid:`. The validator rejects the op when `cid` is missing, empty, or whitespace-only.
Source
Thrown at shortcuts/mail/draft/model.go:327
}
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")
}
case "remove_signature":
// No required fields.View on GitHub (pinned to 7fd6ef3c07)
Solutions
- Add a non-empty `cid` to the add_inline operation
- Reference the same cid in the HTML body (e.g. `<img src="cid:logo1">`) so the inline image renders
- Use a unique, stable cid per inline resource to avoid collisions in multi-image drafts
Example fix
// before
{"op":"add_inline","path":"/tmp/logo.png"}
// after
{"op":"add_inline","path":"/tmp/logo.png","cid":"logo1"} Defensive patterns
Strategy: validation
Validate before calling
if strings.TrimSpace(op.CID) == "" {
return fmt.Errorf("add_inline requires cid")
} Type guard
func hasAddInlineCID(op DraftOp) bool { return strings.TrimSpace(op.CID) != "" } Prevention
- Assign a unique cid to each inline resource and mirror it in the HTML body (cid:...)
- Generate cids programmatically (e.g. img1, img2) rather than leaving them blank
- Remember cid is required only for add_inline, not for add_attachment
When it happens
Trigger: Submitting `{"op":"add_inline","path":"/tmp/logo.png"}` with no `cid`, or `cid: ""` / whitespace only.
Common situations: Attaching an image without wiring the matching `<img src="cid:...">` reference in the HTML body; copying add_attachment ops (no cid needed) and converting them to add_inline without adding a cid.
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
- add_inline requires path
- replace_inline requires target with at least one of part_id
- add_attachment requires path
- remove_attachment requires target with at least one of part_
- target must specify at least one of part_id or cid
AI-assisted analysis of larksuite/cli@7fd6ef3c07 (2026-09-04).
Data as JSON: /api/errors/afeeb9a489939eea.
Report an issue: GitHub.