{"record":{"id":"f1e24b3a0499bbef","repo":"larksuite/cli","slug":"part-q-is-an-inline-mime-part-use-remove-inline","errorCode":null,"errorMessage":"part %q is an inline MIME part; use remove_inline","messagePattern":"part %q is an inline MIME part; use remove_inline","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"shortcuts/mail/draft/patch.go","lineNumber":759,"sourceCode":"\tif snapshot.Body == nil || snapshot.Body.PartID == partID {\n\t\treturn fmt.Errorf(\"cannot remove root MIME part\")\n\t}\n\tif !removePart(snapshot.Body, partID) {\n\t\treturn fmt.Errorf(\"inline part %q not found\", partID)\n\t}\n\treturn nil\n}\n\nfunc removeAttachment(snapshot *DraftSnapshot, partID string) error {\n\tif snapshot.Body == nil {\n\t\treturn fmt.Errorf(\"draft has no MIME body\")\n\t}\n\tpart := findPart(snapshot.Body, partID)\n\tif part == nil {\n\t\treturn fmt.Errorf(\"attachment part %q not found\", partID)\n\t}\n\tif strings.EqualFold(part.ContentDisposition, \"inline\") || part.ContentID != \"\" {\n\t\treturn fmt.Errorf(\"part %q is an inline MIME part; use remove_inline\", partID)\n\t}\n\tif snapshot.Body.PartID == partID {\n\t\treturn fmt.Errorf(\"cannot remove root MIME part\")\n\t}\n\tremoved := removePart(snapshot.Body, partID)\n\tif !removed {\n\t\treturn fmt.Errorf(\"attachment part %q not found\", partID)\n\t}\n\treturn nil\n}\n\nfunc removePart(parent *Part, targetPartID string) bool {\n\tfor idx, child := range parent.Children {\n\t\tif child == nil {\n\t\t\tcontinue\n\t\t}\n\t\tif child.PartID == targetPartID {\n\t\t\tparent.Children = append(parent.Children[:idx], parent.Children[idx+1:]...)","sourceCodeStart":741,"sourceCodeEnd":777,"githubUrl":"https://github.com/larksuite/cli/blob/7fd6ef3c07182257ce776cdc5a614e122d5bd4b3/shortcuts/mail/draft/patch.go#L741-L777","documentation":"The target part exists but is an inline MIME part (Content-Disposition: inline or a non-empty Content-ID), not a downloadable attachment. remove_attachment refuses to delete inline parts because they are referenced from HTML by Content-ID; deleting them silently would break body rendering. The error directs you to the remove_inline operation instead.","triggerScenarios":"Calling remove_attachment with the part_id of a part whose ContentDisposition is \"inline\" or which has a ContentID (cid), typically an embedded image inside multipart/related.","commonSituations":"Agent picked a cid-referenced embedded image thinking it was an attachment; confusing inline embedded images in multipart/related with regular attachments; applying remove_attachment to all parts of a related container.","solutions":["Use the remove_inline operation (with part_id or cid) instead of remove_attachment","Check the part's Content-Disposition/Content-ID in the draft snapshot to classify it before choosing an op","Re-list draft parts and select only parts with disposition attachment"],"exampleFix":"// before\n{\"op\":\"remove_attachment\",\"target\":{\"part_id\":\"img-part\"}}\n// after\n{\"op\":\"remove_inline\",\"target\":{\"cid\":\"image001@domain\"}}","handlingStrategy":"validation","validationCode":"func isInlinePart(p *Part) bool {\n\treturn p != nil && (strings.EqualFold(p.ContentDisposition, \"inline\") || p.ContentID != \"\")\n}\n// choose op: if isInlinePart(part) use remove_inline else remove_attachment","typeGuard":"func isInlinePart(p *Part) bool {\n\treturn p != nil && (strings.EqualFold(p.ContentDisposition, \"inline\") || p.ContentID != \"\")\n}","tryCatchPattern":"if err := applyOp(snap, op); err != nil && strings.Contains(err.Error(), \"inline MIME part\") {\n\top.Name = \"remove_inline\" // switch operation and retry\n}","preventionTips":["Inspect Content-Disposition and Content-ID before selecting remove_attachment vs remove_inline","List parts and bucket them into attachment vs inline first","Never blanket-remove all parts of a multipart/related container"],"tags":["mail","draft","mime","inline","wrong-operation"],"backgroundTag":"wrong-operation-for-mime-part","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"}