{"record":{"id":"427dce9dd1bee50c","repo":"larksuite/cli","slug":"remove-attachment-draft-has-no-large-attachment-h","errorCode":null,"errorMessage":"remove_attachment: draft has no large attachment header","messagePattern":"remove_attachment: draft has no large attachment header","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"shortcuts/mail/draft/large_attachment_parse.go","lineNumber":284,"sourceCode":"\t}\n\treturn nil\n}\n\n// removeTokenFromIDsHeader removes the given token from whichever large\n// attachment header is present (CLI or server format). Returns an error\n// if no header is found or the token is not listed. After removal, the\n// header is re-encoded in CLI format (X-Lms-Large-Attachment-Ids) so\n// the server can process the update on upload.\nfunc removeTokenFromIDsHeader(snapshot *DraftSnapshot, token string) error {\n\theaderIdx := -1\n\tfor i, h := range snapshot.Headers {\n\t\tif IsLargeAttachmentHeader(h.Name) {\n\t\t\theaderIdx = i\n\t\t\tbreak\n\t\t}\n\t}\n\tif headerIdx < 0 {\n\t\treturn fmt.Errorf(\"remove_attachment: draft has no large attachment header\")\n\t}\n\titems, err := decodeLargeAttachmentHeader(snapshot.Headers[headerIdx].Value)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"remove_attachment: malformed large attachment header: %w\", err)\n\t}\n\tfiltered := make([]largeAttHeaderEntry, 0, len(items))\n\tremoved := false\n\tfor _, it := range items {\n\t\tif it.token() == token {\n\t\t\tremoved = true\n\t\t\tcontinue\n\t\t}\n\t\tfiltered = append(filtered, it)\n\t}\n\tif !removed {\n\t\treturn fmt.Errorf(\"remove_attachment: token %q not found in large attachment header\", token)\n\t}\n\tif len(filtered) == 0 {","sourceCodeStart":266,"sourceCodeEnd":302,"githubUrl":"https://github.com/larksuite/cli/blob/7fd6ef3c07182257ce776cdc5a614e122d5bd4b3/shortcuts/mail/draft/large_attachment_parse.go#L266-L302","documentation":"Guard in removeTokenFromIDsHeader: the draft snapshot has no large-attachment ID header (either CLI or server format), so there is no large attachment registered to remove.","triggerScenarios":"Thrown at shortcuts/mail/draft/large_attachment_parse.go:284 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Verify the draft actually has large attachments before calling remove_attachment"],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"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"}