larksuite/cli · error
replace_inline requires target with at least one of part_id
Error message
replace_inline requires target with at least one of part_id or cid
What it means
A `replace_inline` operation swaps the content of an existing inline resource, so it must first identify that resource via `part_id` or `cid` in its `target` object. If the target lacks both keys, the validator rejects the op because it cannot determine which inline resource to replace.
Source
Thrown at shortcuts/mail/draft/model.go:331
}
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.
case "set_calendar":
if strings.TrimSpace(op.EventSummary) == "" {
return fmt.Errorf("set_calendar requires event_summary")
}View on GitHub (pinned to 7fd6ef3c07)
Solutions
- Add `part_id` or `cid` to the operation's `target` object identifying the inline resource to replace
- Fetch the current draft to obtain the existing inline resource's part_id or cid before replacing
- Ensure `path` is also set, since replace_inline additionally requires the replacement file
Example fix
// before
{"op":"replace_inline","path":"/tmp/new-logo.png"}
// after
{"op":"replace_inline","target":{"cid":"logo1"},"path":"/tmp/new-logo.png"} Defensive patterns
Strategy: validation
Validate before calling
if !op.Target.hasKey() {
return fmt.Errorf("replace_inline requires target with at least one of part_id or cid")
} Type guard
func inlineTargetIdentified(t Target) bool { return t.hasKey() } Prevention
- Fetch the draft to get part_id or cid before replacing an inline resource
- Note replace_inline accepts only part_id or cid, not token
- Always pair the target with a non-empty path for the replacement file
When it happens
Trigger: Submitting `{"op":"replace_inline","path":"/tmp/new.png"}` with no `target`, `target: {}`, or a target containing only keys other than part_id/cid (e.g. token, which remove_attachment accepts but replace_inline does not — hasKey() checks only part_id and cid).
Common situations: Replacing an inline image without first reading the draft to get its part_id or cid; reusing a remove_attachment-style target that used token; target JSON nested at the wrong level.
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
- add_inline requires cid
- 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/1bf851c690142951.
Report an issue: GitHub.