{"record":{"id":"4e69c2e554929a29","repo":"larksuite/cli","slug":"remove-signature-no-html-body-part-found","errorCode":null,"errorMessage":"remove_signature: no HTML body part found","messagePattern":"remove_signature: no HTML body part found","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"shortcuts/mail/draft/patch.go","lineNumber":1261,"sourceCode":"\t}\n\n\thtmlPart.Body = []byte(newHTML)\n\thtmlPart.Dirty = true\n\n\t// Add new signature inline images to the MIME tree.\n\tfor _, img := range op.SignatureImages {\n\t\taddInlinePartToSnapshot(snapshot, img.Data, img.ContentType, img.FileName, img.CID)\n\t}\n\n\tsyncTextPartFromHTML(snapshot, newHTML)\n\treturn nil\n}\n\n// removeSignatureOp removes the signature block from the HTML body.\nfunc removeSignatureOp(snapshot *DraftSnapshot) error {\n\thtmlPart := findPart(snapshot.Body, snapshot.PrimaryHTMLPartID)\n\tif htmlPart == nil {\n\t\treturn fmt.Errorf(\"remove_signature: no HTML body part found\")\n\t}\n\thtml := string(htmlPart.Body)\n\n\tif !signatureWrapperRe.MatchString(html) {\n\t\treturn fmt.Errorf(\"no signature found in draft body\")\n\t}\n\n\t// Collect CIDs referenced by the signature before removing it.\n\tsigCIDs := collectSignatureCIDsFromHTML(html)\n\n\t// Remove signature and preceding spacing.\n\thtml = RemoveSignatureHTML(html)\n\n\t// Remove orphaned inline parts (only if the CID is no longer referenced in remaining HTML).\n\tfor _, cid := range sigCIDs {\n\t\tif !containsCIDIgnoreCase(html, cid) {\n\t\t\tremoveMIMEPartByCID(snapshot.Body, cid)\n\t\t}","sourceCodeStart":1243,"sourceCodeEnd":1279,"githubUrl":"https://github.com/larksuite/cli/blob/7fd6ef3c07182257ce776cdc5a614e122d5bd4b3/shortcuts/mail/draft/patch.go#L1243-L1279","documentation":"removeSignatureOp locates the primary HTML part before attempting signature removal. If the snapshot has no HTML body part at all, there is no signature to remove and no place to look, so it fails with this error, distinct from the 'no signature found' error that fires only when the HTML exists but lacks a signature wrapper.","triggerScenarios":"Applying a remove_signature op to a snapshot whose Body has no HTML part (no set_body ever ran, or the draft is plain-text-only) so findPart returns nil.","commonSituations":"Trying to remove a signature from a plain-text-only draft; a snapshot built by a different path that never produced an HTML alternative; misordered patch pipeline where set_body was skipped.","solutions":["Ensure the draft has an HTML body part (set_body) before remove_signature","Skip the remove_signature op when the draft has no HTML part (nothing to remove)","Check PrimaryHTMLPartID correctness if parts exist but are not being found"],"exampleFix":"// before\napplyOp(snapshot, PatchOp{Type: \"remove_signature\"}) // plain-text draft\n// after\nif findPart(snapshot.Body, snapshot.PrimaryHTMLPartID) != nil {\n  applyOp(snapshot, PatchOp{Type: \"remove_signature\"})\n}","handlingStrategy":"type-guard","validationCode":null,"typeGuard":"func canRemoveSignature(s *DraftSnapshot) bool {\n  return s != nil && findPart(s.Body, s.PrimaryHTMLPartID) != nil\n}","tryCatchPattern":"err := applyOp(snapshot, op)\nif err != nil && strings.Contains(err.Error(), \"remove_signature: no HTML body part found\") {\n  return nil // nothing to remove; treat as no-op\n}","preventionTips":["Skip remove_signature for plain-text-only drafts","Ensure set_body ran earlier in the pipeline","Track whether a signature was ever inserted"],"tags":["mail","draft-patch","signature","precondition"],"backgroundTag":"missing-html-body-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"}