{"record":{"id":"afeeb9a489939eea","repo":"larksuite/cli","slug":"add-inline-requires-cid","errorCode":null,"errorMessage":"add_inline requires cid","messagePattern":"add_inline requires cid","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"shortcuts/mail/draft/model.go","lineNumber":327,"sourceCode":"\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() {\n\t\t\treturn fmt.Errorf(\"replace_inline requires target with at least one of part_id or cid\")\n\t\t}\n\t\tif strings.TrimSpace(op.Path) == \"\" {\n\t\t\treturn fmt.Errorf(\"replace_inline requires path\")\n\t\t}\n\tcase \"remove_inline\":\n\t\tif !op.Target.hasKey() {\n\t\t\treturn fmt.Errorf(\"remove_inline requires target with at least one of part_id or cid\")\n\t\t}\n\tcase \"insert_signature\":\n\t\tif strings.TrimSpace(op.SignatureID) == \"\" {\n\t\t\treturn fmt.Errorf(\"insert_signature requires signature_id\")\n\t\t}\n\tcase \"remove_signature\":\n\t\t// No required fields.","sourceCodeStart":309,"sourceCodeEnd":345,"githubUrl":"https://github.com/larksuite/cli/blob/7fd6ef3c07182257ce776cdc5a614e122d5bd4b3/shortcuts/mail/draft/model.go#L309-L345","documentation":"An `add_inline` operation requires a `cid` (Content-ID) in addition to `path`, because the embedded file must be referenced from the HTML body via `cid:`. The validator rejects the op when `cid` is missing, empty, or whitespace-only.","triggerScenarios":"Submitting `{\"op\":\"add_inline\",\"path\":\"/tmp/logo.png\"}` with no `cid`, or `cid: \"\"` / whitespace only.","commonSituations":"Attaching an image without wiring the matching `<img src=\"cid:...\">` reference in the HTML body; copying add_attachment ops (no cid needed) and converting them to add_inline without adding a cid.","solutions":["Add a non-empty `cid` to the add_inline operation","Reference the same cid in the HTML body (e.g. `<img src=\"cid:logo1\">`) so the inline image renders","Use a unique, stable cid per inline resource to avoid collisions in multi-image drafts"],"exampleFix":"// before\n{\"op\":\"add_inline\",\"path\":\"/tmp/logo.png\"}\n// after\n{\"op\":\"add_inline\",\"path\":\"/tmp/logo.png\",\"cid\":\"logo1\"}","handlingStrategy":"validation","validationCode":"if strings.TrimSpace(op.CID) == \"\" {\n    return fmt.Errorf(\"add_inline requires cid\")\n}","typeGuard":"func hasAddInlineCID(op DraftOp) bool { return strings.TrimSpace(op.CID) != \"\" }","tryCatchPattern":null,"preventionTips":["Assign a unique cid to each inline resource and mirror it in the HTML body (cid:...)","Generate cids programmatically (e.g. img1, img2) rather than leaving them blank","Remember cid is required only for add_inline, not for add_attachment"],"tags":["validation","mail","draft","inline-image","cid","missing-field"],"backgroundTag":"missing-required-argument","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"}