{"record":{"id":"27d6282584c7eec2","repo":"larksuite/cli","slug":"patch-ops-is-required","errorCode":null,"errorMessage":"patch ops is required","messagePattern":"patch ops is required","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"shortcuts/mail/draft/model.go","lineNumber":252,"sourceCode":"\n\t// CalendarICS holds the pre-built RFC 5545 ICS blob for a set_calendar\n\t// op. Populated by the shortcut layer after the snapshot is parsed and\n\t// organizer/attendee addresses can be resolved. Not serialised.\n\tCalendarICS []byte `json:\"-\"`\n}\n\n// SignatureImage holds pre-downloaded image data for signature inline images.\n// Populated by the shortcut layer, consumed by the patch layer.\ntype SignatureImage struct {\n\tCID         string\n\tContentType string\n\tFileName    string\n\tData        []byte\n}\n\nfunc (p Patch) Validate() error {\n\tif len(p.Ops) == 0 {\n\t\treturn fmt.Errorf(\"patch ops is required\")\n\t}\n\tfor i, op := range p.Ops {\n\t\tif err := op.Validate(); err != nil {\n\t\t\treturn fmt.Errorf(\"invalid patch op #%d: %w\", i+1, err)\n\t\t}\n\t}\n\treturn nil\n}\n\nfunc (op PatchOp) Validate() error {\n\tswitch op.Op {\n\tcase \"set_subject\":\n\t\tif strings.TrimSpace(op.Value) == \"\" {\n\t\t\treturn fmt.Errorf(\"set_subject requires value\")\n\t\t}\n\t\tif strings.ContainsAny(op.Value, \"\\r\\n\") {\n\t\t\treturn fmt.Errorf(\"set_subject: value must not contain CR or LF\")\n\t\t}","sourceCodeStart":234,"sourceCodeEnd":270,"githubUrl":"https://github.com/larksuite/cli/blob/7fd6ef3c07182257ce776cdc5a614e122d5bd4b3/shortcuts/mail/draft/model.go#L234-L270","documentation":"Guard in Patch.Validate: the patch contains zero ops; a mail draft patch must perform at least one operation.","triggerScenarios":"Thrown at shortcuts/mail/draft/model.go:252 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Include at least one patch op"],"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"}