{"record":{"id":"3f44c289ed6bde45","repo":"siyuan-note/siyuan","slug":"unsupported-template-operation","errorCode":null,"errorMessage":"unsupported template operation","messagePattern":"unsupported template operation","errorType":"error_code","errorClass":null,"httpStatus":null,"severity":"error","filePath":"kernel/model/template_manage.go","lineNumber":316,"sourceCode":"\t\t}\n\t\tif err = validateNewTemplateName(request.Target); err != nil {\n\t\t\treturn nil, err\n\t\t}\n\t\tif !info.IsDir() && !strings.EqualFold(path.Ext(request.Target), \".md\") {\n\t\t\treturn nil, errors.New(\"template source must use the .md extension\")\n\t\t}\n\t\tif _, err = root.Stat(request.Target); !errors.Is(err, os.ErrNotExist) {\n\t\t\treturn nil, errors.New(\"template destination already exists or is inaccessible\")\n\t\t}\n\t\treturn nil, root.Rename(request.Path, request.Target)\n\tcase \"remove\":\n\t\t// 路径边界和版本校验完成后，直接删除选中项目及其内容。\n\t\tif info.IsDir() {\n\t\t\treturn nil, root.RemoveAll(request.Path)\n\t\t}\n\t\treturn nil, root.Remove(request.Path)\n\tdefault:\n\t\treturn nil, errors.New(\"unsupported template operation\")\n\t}\n}\n","sourceCodeStart":298,"sourceCodeEnd":319,"githubUrl":"https://github.com/siyuan-note/siyuan/blob/9f775e8a12daef8255556097396f9b2739078892/kernel/model/template_manage.go#L298-L319","documentation":"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.","triggerScenarios":"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).","commonSituations":"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.","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"],"exampleFix":"// before\nreq := TemplateFileRequest{Action: \"delete\", Path: \"t.md\"}\n// after\nreq := TemplateFileRequest{Action: \"remove\", Path: \"t.md\"}","handlingStrategy":"validation","validationCode":"var validActions = map[string]bool{\"list\":true,\"mkdir\":true,\"read\":true,\"write\":true,\"move\":true,\"remove\":true}\nif !validActions[action] { return fmt.Errorf(\"unsupported action %q\", action) }","typeGuard":"func isValidTemplateAction(a string) bool { switch a { case \"list\",\"mkdir\",\"read\",\"write\",\"move\",\"remove\": return true }; return false }","tryCatchPattern":null,"preventionTips":["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"],"tags":["unsupported-operation","api","enum"],"backgroundTag":"unsupported-operation","analyzedSha":"9f775e8a12daef8255556097396f9b2739078892","analyzedAt":"2026-09-19T03:17:15.984Z","contentChangedAt":"2026-09-19T03:17:15.984Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}