{"record":{"id":"38ea9a218a5ed74d","repo":"larksuite/cli","slug":"invalid-patch-op-d-w","errorCode":null,"errorMessage":"invalid patch op #%d: %w","messagePattern":"invalid patch op #(.+?): %w","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"shortcuts/mail/draft/model.go","lineNumber":256,"sourceCode":"\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}\n\tcase \"set_recipients\":\n\t\tif !isRecipientField(op.Field) {\n\t\t\treturn fmt.Errorf(\"recipient field must be one of to/cc/bcc\")\n\t\t}","sourceCodeStart":238,"sourceCodeEnd":274,"githubUrl":"https://github.com/larksuite/cli/blob/7fd6ef3c07182257ce776cdc5a614e122d5bd4b3/shortcuts/mail/draft/model.go#L238-L274","documentation":"Wrapper in Patch.Validate: the op at the given 1-based index failed its own validation; the underlying op error is preserved as the cause.","triggerScenarios":"Thrown at shortcuts/mail/draft/model.go:256 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Fix the flagged op per the wrapped error"],"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"}