{"record":{"id":"4acc97f9b6f48ab2","repo":"larksuite/cli","slug":"remove-inline-w","errorCode":null,"errorMessage":"remove_inline: %w","messagePattern":"remove_inline: %w","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"shortcuts/mail/draft/patch.go","lineNumber":133,"sourceCode":"\t\t\t}\n\t\t}\n\t\tpartID, err := resolveTarget(snapshot, tgt)\n\t\tif err != nil {\n\t\t\treturn fmt.Errorf(\"remove_attachment: %w\", err)\n\t\t}\n\t\treturn removeAttachment(snapshot, partID)\n\tcase \"add_inline\":\n\t\treturn addInline(dctx, snapshot, op.Path, op.CID, op.FileName, op.ContentType)\n\tcase \"replace_inline\":\n\t\tpartID, err := resolveTarget(snapshot, op.Target)\n\t\tif err != nil {\n\t\t\treturn fmt.Errorf(\"replace_inline: %w\", err)\n\t\t}\n\t\treturn replaceInline(dctx, snapshot, partID, op.Path, op.CID, op.FileName, op.ContentType)\n\tcase \"remove_inline\":\n\t\tpartID, err := resolveTarget(snapshot, op.Target)\n\t\tif err != nil {\n\t\t\treturn fmt.Errorf(\"remove_inline: %w\", err)\n\t\t}\n\t\treturn removeInline(snapshot, partID)\n\tcase \"insert_signature\":\n\t\treturn insertSignatureOp(snapshot, op)\n\tcase \"remove_signature\":\n\t\treturn removeSignatureOp(snapshot)\n\tcase \"set_calendar\":\n\t\treturn applyCalendarSet(snapshot, op.CalendarICS)\n\tcase \"remove_calendar\":\n\t\treturn applyCalendarRemove(snapshot)\n\tdefault:\n\t\treturn fmt.Errorf(\"unsupported patch op %q\", op.Op)\n\t}\n\treturn nil\n}\n\nfunc ensureHeaderEditable(name string, options PatchOptions) error {\n\tif protectedHeaders[strings.ToLower(strings.TrimSpace(name))] && !options.AllowProtectedHeaderEdits {","sourceCodeStart":115,"sourceCodeEnd":151,"githubUrl":"https://github.com/larksuite/cli/blob/7fd6ef3c07182257ce776cdc5a614e122d5bd4b3/shortcuts/mail/draft/patch.go#L115-L151","documentation":"Wrapper around a resolveTarget failure during the 'remove_inline' op. The Target could not be resolved to an existing inline-image part in the snapshot; the concrete cause (missing part, wrong type, bad locator) is wrapped and preserved.","triggerScenarios":"Calling Apply with PatchOp{Op:\"remove_inline\"} whose Target is a nonexistent partID, already-removed part, or a part that is not an inline image.","commonSituations":"Removing inline images from a stale snapshot after prior patches; confusing attachment partIDs with inline partIDs; idempotent retry of an already-applied removal.","solutions":["Read the wrapped cause (errors.Unwrap) to identify the resolution failure.","Re-fetch a fresh DraftSnapshot before the removal.","Locate the inline part by CID rather than guessing a partID.","Skip the op if the part is already gone to make the patch idempotent."],"exampleFix":"// before\nops := []PatchOp{{Op: \"remove_inline\", Target: Target{PartID: guessedID}}}\n// after\nsnapshot := fetchFreshSnapshot(dctx)\nif id, ok := findInlinePartByCID(snapshot, cid); ok {\n    ops := []PatchOp{{Op: \"remove_inline\", Target: Target{PartID: id}}}\n}","handlingStrategy":"validation","validationCode":"func canRemoveInline(snap *DraftSnapshot, tgt Target) error {\n    _, err := resolveTarget(snap, tgt)\n    return err\n} // call before building the op","typeGuard":"func inlinePartExists(snap *DraftSnapshot, tgt Target) bool {\n    p, err := resolveTarget(snap, tgt)\n    return err == nil && p != nil && p.ContentID != \"\"\n}","tryCatchPattern":"if err := Apply(ctx, dctx, ops, opts); err != nil {\n    if strings.HasPrefix(err.Error(), \"remove_inline:\") {\n        return fmt.Errorf(\"inline part already gone or wrong type; refresh snapshot: %w\", err)\n    }\n    return err\n}","preventionTips":["Fetch a fresh snapshot immediately before removal ops.","Locate inline parts by CID rather than hard-coded partIDs.","Skip removal if the target is already absent (idempotency).","Never reuse partIDs across snapshot versions."],"tags":["email","draft-patch","invalid-target"],"backgroundTag":"invalid-target-reference","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"}