{"record":{"id":"a8a77a96737b8b5e","repo":"larksuite/cli","slug":"remove-header-requires-name","errorCode":null,"errorMessage":"remove_header requires name","messagePattern":"remove_header requires name","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"shortcuts/mail/draft/model.go","lineNumber":312,"sourceCode":"\t\tif !isBodyKind(op.BodyKind) {\n\t\t\treturn fmt.Errorf(\"body_kind must be text/plain or text/html\")\n\t\t}\n\t\tif op.Selector != \"\" && op.Selector != \"primary\" {\n\t\t\treturn fmt.Errorf(\"selector must be primary\")\n\t\t}\n\tcase \"set_header\":\n\t\tif strings.TrimSpace(op.Name) == \"\" {\n\t\t\treturn fmt.Errorf(\"set_header requires name\")\n\t\t}\n\t\tif strings.ContainsAny(op.Name, \":\\r\\n\") {\n\t\t\treturn fmt.Errorf(\"set_header: header name must not contain ':', CR, or LF\")\n\t\t}\n\t\tif strings.ContainsAny(op.Value, \"\\r\\n\") {\n\t\t\treturn fmt.Errorf(\"set_header: header value must not contain CR or LF\")\n\t\t}\n\tcase \"remove_header\":\n\t\tif strings.TrimSpace(op.Name) == \"\" {\n\t\t\treturn fmt.Errorf(\"remove_header requires name\")\n\t\t}\n\tcase \"add_attachment\":\n\t\tif strings.TrimSpace(op.Path) == \"\" {\n\t\t\treturn fmt.Errorf(\"add_attachment requires path\")\n\t\t}\n\tcase \"remove_attachment\":\n\t\tif !op.Target.hasAnyKey() {\n\t\t\treturn fmt.Errorf(\"remove_attachment requires target with at least one of part_id, cid, or token\")\n\t\t}\n\tcase \"add_inline\":\n\t\tif strings.TrimSpace(op.Path) == \"\" {\n\t\t\treturn fmt.Errorf(\"add_inline requires path\")\n\t\t}\n\t\tif strings.TrimSpace(op.CID) == \"\" {\n\t\t\treturn fmt.Errorf(\"add_inline requires cid\")\n\t\t}\n\tcase \"replace_inline\":\n\t\tif !op.Target.hasKey() {","sourceCodeStart":294,"sourceCodeEnd":330,"githubUrl":"https://github.com/larksuite/cli/blob/7fd6ef3c07182257ce776cdc5a614e122d5bd4b3/shortcuts/mail/draft/model.go#L294-L330","documentation":"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.","triggerScenarios":"{\"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.","commonSituations":"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.","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."],"exampleFix":"// before\n{\"op\":\"remove_header\",\"name\":\"\"}\n\n// after\n{\"op\":\"remove_header\",\"name\":\"X-Custom-Id\"}","handlingStrategy":"validation","validationCode":"if strings.TrimSpace(op.Name) == \"\" {\n    return fmt.Errorf(\"remove_header needs a name\")\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["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."],"tags":["mail","validation","patch-op","headers"],"backgroundTag":"empty-required-field","analyzedSha":"7fd6ef3c07182257ce776cdc5a614e122d5bd4b3","analyzedAt":"2026-09-04T21:17:44.649Z","contentChangedAt":"2026-09-04T21:17:44.649Z","schemaVersion":2},"datasetVersion":"2026-09-12T02:17:10.037Z"}