larksuite/cli · error
remove_header requires name
Error message
remove_header requires name
What it means
Thrown by PatchOp.Validate() in shortcuts/mail/draft/model.go:312 when a remove_header op has an empty or whitespace-only Name. Removing a header requires identifying which one, so the name is mandatory. Unlike set_header, this op takes no value.
Source
Thrown at shortcuts/mail/draft/model.go:312
if !isBodyKind(op.BodyKind) {
return fmt.Errorf("body_kind must be text/plain or text/html")
}
if op.Selector != "" && op.Selector != "primary" {
return fmt.Errorf("selector must be primary")
}
case "set_header":
if strings.TrimSpace(op.Name) == "" {
return fmt.Errorf("set_header requires name")
}
if strings.ContainsAny(op.Name, ":\r\n") {
return fmt.Errorf("set_header: header name must not contain ':', CR, or LF")
}
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() {View on GitHub (pinned to 7fd6ef3c07)
Solutions
- Set op.Name to the exact header name to remove, e.g. {"op":"remove_header","name":"X-Custom-Id"}.
- To remove several headers, emit one remove_header op per name.
- Validate the names list before constructing ops and skip blank entries.
Example fix
// before
{"op":"remove_header","name":""}
// after
{"op":"remove_header","name":"X-Custom-Id"} Defensive patterns
Strategy: validation
Validate before calling
if strings.TrimSpace(op.Name) == "" {
return fmt.Errorf("remove_header needs a name")
} Prevention
- One remove_header op per header — blank names cannot mean "remove all".
- Trim and check names when building remove ops from a list.
- Fetch the draft snapshot first if unsure of the exact header names to remove.
When it happens
Trigger: {"op":"remove_header"} with no name key; name:"" after a variable feeding it was empty; building remove ops from a list of header names where one entry is blank.
Common situations: Removing all headers via a blank name (unsupported — remove one at a time); a derived name computed from a prefix that turned out empty; omitempty dropping an empty name during JSON serialization.
Understand the failure class
Background: "must not be empty", "cannot be empty" — required-field validation errors across open-source libraries — this error's family across 41 libraries.
Related errors
- set_header requires name
- set_header: header name must not contain ':', CR, or LF
- set_header: header value must not contain CR or LF
- set_recipients requires non-empty addresses
- %s requires address
AI-assisted analysis of larksuite/cli@7fd6ef3c07 (2026-09-04).
Data as JSON: /api/errors/a8a77a96737b8b5e.
Report an issue: GitHub.