siyuan-note/siyuan · error
unsupported template operation
Error message
unsupported template operation
What it means
ManageTemplateFiles dispatches on request.Action and supports exactly: list, mkdir, read, write, move, remove. Any other Action string falls through the switch to this error. It is a guard against typo'd or newer-protocol actions sent to an older kernel.
Solutions
- Use one of the supported actions: list, mkdir, read, write, move, remove
- Map synonyms before calling (delete→remove, rename→move, copy→read+write)
- Check kernel version alignment if a newer client sends newer actions to an older kernel
- Validate the Action string against the allowed set in client code before invoking
Example fix
// before
req := TemplateFileRequest{Action: "delete", Path: "t.md"}
// after
req := TemplateFileRequest{Action: "remove", Path: "t.md"} Defensive patterns
Strategy: validation
Validate before calling
var validActions = map[string]bool{"list":true,"mkdir":true,"read":true,"write":true,"move":true,"remove":true}
if !validActions[action] { return fmt.Errorf("unsupported action %q", action) } Type guard
func isValidTemplateAction(a string) bool { switch a { case "list","mkdir","read","write","move","remove": return true }; return false } Prevention
- Use the exact action verbs: remove (not delete), move (not rename)
- Keep client and kernel versions aligned
- Define the action as a typed constant set in client code
When it happens
Trigger: Calling ManageTemplateFiles with Action set to anything other than "list", "mkdir", "read", "write", "move", or "remove" (e.g. "delete", "rename", "copy", or an empty string not caught earlier).
Common situations: API clients using synonyms like "delete" instead of "remove" or "rename" instead of "move"; version skew where a newer frontend sends an action the running kernel does not know; constructing the request struct programmatically with an unset Action field.
Understand the failure class
Background: UnsupportedOperationException and "is not supported" errors: when a library deliberately refuses a call — this error's family across 30 libraries.
Related errors
- Field [mode] must be 0 or 1
- invalid block ref check scope
- invalid pinned document action
- Source content is only supported for template preview
- unsupported block operation
AI-assisted analysis of siyuan-note/siyuan@9f775e8a12 (2026-09-19).
Data as JSON: /api/errors/3f44c289ed6bde45.
Report an issue: GitHub.
Appendix: source
Thrown at kernel/model/template_manage.go:316
}
if err = validateNewTemplateName(request.Target); err != nil {
return nil, err
}
if !info.IsDir() && !strings.EqualFold(path.Ext(request.Target), ".md") {
return nil, errors.New("template source must use the .md extension")
}
if _, err = root.Stat(request.Target); !errors.Is(err, os.ErrNotExist) {
return nil, errors.New("template destination already exists or is inaccessible")
}
return nil, root.Rename(request.Path, request.Target)
case "remove":
// 路径边界和版本校验完成后,直接删除选中项目及其内容。
if info.IsDir() {
return nil, root.RemoveAll(request.Path)
}
return nil, root.Remove(request.Path)
default:
return nil, errors.New("unsupported template operation")
}
}
View on GitHub (pinned to 9f775e8a12)