{"record":{"id":"cf10dde91141e224","repo":"larksuite/cli","slug":"no-part-with-cid-q-found","errorCode":null,"errorMessage":"no part with cid %q found","messagePattern":"no part with cid %q found","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"shortcuts/mail/draft/patch.go","lineNumber":799,"sourceCode":"\t\tif removePart(child, targetPartID) {\n\t\t\tparent.Dirty = true\n\t\t\treturn true\n\t\t}\n\t}\n\treturn false\n}\n\n// resolveTarget resolves an AttachmentTarget to a concrete part_id.\n// Priority: part_id > cid.\nfunc resolveTarget(snapshot *DraftSnapshot, target AttachmentTarget) (string, error) {\n\tif id := strings.TrimSpace(target.PartID); id != \"\" {\n\t\treturn id, nil\n\t}\n\tif cid := strings.TrimSpace(target.CID); cid != \"\" {\n\t\tcid = strings.Trim(cid, \"<>\")\n\t\tpart := findPartByCID(snapshot.Body, cid)\n\t\tif part == nil {\n\t\t\treturn \"\", fmt.Errorf(\"no part with cid %q found\", cid)\n\t\t}\n\t\treturn part.PartID, nil\n\t}\n\treturn \"\", fmt.Errorf(\"target must specify at least one of part_id or cid\")\n}\n\nfunc findPartByCID(root *Part, cid string) *Part {\n\tif root == nil {\n\t\treturn nil\n\t}\n\tif strings.EqualFold(strings.Trim(root.ContentID, \"<>\"), cid) {\n\t\treturn root\n\t}\n\tfor _, child := range root.Children {\n\t\tif found := findPartByCID(child, cid); found != nil {\n\t\t\treturn found\n\t\t}\n\t}","sourceCodeStart":781,"sourceCodeEnd":817,"githubUrl":"https://github.com/larksuite/cli/blob/7fd6ef3c07182257ce776cdc5a614e122d5bd4b3/shortcuts/mail/draft/patch.go#L781-L817","documentation":"resolveTarget translates an inline-target's cid into a part_id by searching the MIME tree with findPartByCID; when no part carries a matching Content-ID, it returns this error. CIDs are matched after trimming surrounding angle brackets, but the cid must otherwise correspond to an existing inline part in the current draft body.","triggerScenarios":"Calling an inline patch op (e.g. remove_inline/replace_inline) with target.cid that does not match any part's Content-ID — wrong cid, cid from a different draft, or the inline part was already removed/rewritten in an earlier op.","commonSituations":"Citing the cid from the original source HTML after the draft's inline parts were regenerated; case/angle-bracket or whitespace mismatches; referencing cid from a previous draft version.","solutions":["Re-read the draft and use a cid that currently exists in the MIME tree (or target by part_id instead)","Strip angle brackets and whitespace and match cid exactly as stored","If the part was removed earlier in the same patch, drop this op","Verify the draft you are patching is the same one the cid came from"],"exampleFix":"// before\n{\"op\":\"remove_inline\",\"target\":{\"cid\":\"stale-cid@old-draft\"}}\n// after — refresh snapshot first\n{\"op\":\"remove_inline\",\"target\":{\"cid\":\"image001@current-draft\"}}","handlingStrategy":"validation","validationCode":"func cidExists(snap *DraftSnapshot, cid string) bool {\n\treturn findPartByCID(snap.Body, strings.Trim(strings.TrimSpace(cid), \"<>\")) != nil\n}","typeGuard":"func partHasCID(p *Part, cid string) bool {\n\treturn p != nil && strings.Trim(p.ContentID, \"<>\") == strings.Trim(cid, \"<>\")\n}","tryCatchPattern":"if err := applyOp(snap, op); err != nil && strings.Contains(err.Error(), \"no part with cid\") {\n\t// refresh snapshot, re-list cids, then rebuild the op\n}","preventionTips":["Re-fetch the draft and enumerate existing cids before referencing one","Normalize cids: trim whitespace and angle brackets, match case exactly","Drop ops for parts already removed earlier in the same patch","Prefer part_id when you have it; cid lookup only when the ID is unknown"],"tags":["mail","draft","mime","cid","not-found"],"backgroundTag":"mime-cid-not-found","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"}