larksuite/cli · error
unsupported op %q
Error message
unsupported op %q
What it means
The draft patch validator switches on op.Op and only recognizes the ops defined in the switch (set_header, remove_header, add_attachment, add_inline, set_calendar, remove_calendar, etc.). Any other string — including typos, wrong casing, or ops from a different command — hits the default branch and is rejected. The offending op name is quoted in the message.
Source
Thrown at shortcuts/mail/draft/model.go:367
}
if strings.TrimSpace(op.EventStart) == "" || strings.TrimSpace(op.EventEnd) == "" {
return fmt.Errorf("set_calendar requires event_start and event_end")
}
start, err := parseISO8601(op.EventStart)
if err != nil {
return fmt.Errorf("set_calendar: event_start must be a valid ISO 8601 timestamp")
}
end, err := parseISO8601(op.EventEnd)
if err != nil {
return fmt.Errorf("set_calendar: event_end must be a valid ISO 8601 timestamp")
}
if !end.After(start) {
return fmt.Errorf("set_calendar: event_end must be after event_start")
}
case "remove_calendar":
// No required fields.
default:
return fmt.Errorf("unsupported op %q", op.Op)
}
return nil
}
func isRecipientField(field string) bool {
switch strings.ToLower(strings.TrimSpace(field)) {
case "to", "cc", "bcc":
return true
default:
return false
}
}
func isBodyKind(kind string) bool {
switch strings.ToLower(strings.TrimSpace(kind)) {
case "text/plain", "text/html":
return true
default:View on GitHub (pinned to 7fd6ef3c07)
Solutions
- Run lark-cli with --help or schema on the draft patch command to list the supported op names
- Match the op string exactly, lowercase with underscores (e.g. "set_calendar", not "setCalendar" or "set_calender")
- Check for typos like transposed letters (calender vs calendar)
- If the op genuinely does not exist, use the generic API command to call the endpoint directly instead of inventing an op
Example fix
// before
{"op": "set_calender", "event_summary": "Sync", ...}
// after
{"op": "set_calendar", "event_summary": "Sync", ...} Defensive patterns
Strategy: validation
Validate before calling
var supportedOps = map[string]bool{
"set_header": true, "remove_header": true, "add_attachment": true,
"add_inline": true, "replace_inline": true, "remove_inline": true,
"insert_signature": true, "remove_signature": true,
"set_calendar": true, "remove_calendar": true,
}
if !supportedOps[op.Op] {
return fmt.Errorf("unknown op %q", op.Op)
} Prevention
- Keep op names in a shared constant list or enum rather than inline literals
- Check `lark-cli ... --help` / `schema` output for the exact op vocabulary before scripting
- Beware of typos (calender) and casing variants — ops are matched case-sensitively
- Do not invent ops; fall back to the generic API command for unmodeled endpoints
When it happens
Trigger: Submitting a Patch whose op.Op is a typo ("set_calender", "setCalendar"), capitalized ("Set_Calendar"), or a made-up op name; passing JSON op objects with an 'op' field the CLI does not implement.
Common situations: Hand-written op scripts with typos; docs or blog snippets referencing an older/newer op set; case-sensitivity mistakes; reusing ops from another shortcut domain in a mail draft patch.
Understand the failure class
Background: Invalid enum value errors: "Unknown type", "Invalid scope", "must be one of" — when a string is not on the library's allowed list — this error's family across 23 libraries.
Related errors
- %s contains unknown field %q
- set_calendar: event_start must be a valid ISO 8601 timestamp
- set_calendar: event_end must be a valid ISO 8601 timestamp
- set_calendar: event_end must be after event_start
- unsupported patch op %q
AI-assisted analysis of larksuite/cli@7fd6ef3c07 (2026-09-04).
Data as JSON: /api/errors/5b159cb0843bc220.
Report an issue: GitHub.