{"record":{"id":"a2ea7a4d783803a2","repo":"siyuan-note/siyuan","slug":"content-template-s-not-found","errorCode":null,"errorMessage":"content template [%s] not found","messagePattern":"content template \\[(.+?)\\] not found","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"kernel/model/template.go","lineNumber":718,"sourceCode":"\t}\n\ttree.Root.SetIALAttr(\"updated\", util.CurrentTimeSecondsStr())\n\treturn indexWriteTreeUpsertQueue(tree)\n}\n\nfunc resolveDocContentTemplatePath(templatePath string) (string, error) {\n\ttemplatePath = strings.TrimPrefix(filepath.ToSlash(strings.TrimSpace(templatePath)), \"/\")\n\tcleanPath := filepath.Clean(filepath.FromSlash(templatePath))\n\tif \"\" == cleanPath || \".\" == cleanPath || filepath.IsAbs(cleanPath) || \"..\" == cleanPath ||\n\t\tstrings.HasPrefix(cleanPath, \"..\"+string(os.PathSeparator)) {\n\t\treturn \"\", errors.New(\"invalid content template path\")\n\t}\n\ttemplateRoot := filepath.Join(util.DataDir, \"templates\")\n\tabsPath := filepath.Join(templateRoot, cleanPath)\n\tif !gulu.File.IsSubPath(templateRoot, absPath) {\n\t\treturn \"\", errors.New(\"content template path is outside templates directory\")\n\t}\n\tif !filelock.IsExist(absPath) {\n\t\treturn \"\", fmt.Errorf(\"content template [%s] not found\", templatePath)\n\t}\n\trealRoot, err := filepath.EvalSymlinks(templateRoot)\n\tif nil != err {\n\t\treturn \"\", err\n\t}\n\trealPath, err := filepath.EvalSymlinks(absPath)\n\tif nil != err {\n\t\treturn \"\", err\n\t}\n\tinfo, err := os.Stat(realPath)\n\tif nil != err || !info.Mode().IsRegular() {\n\t\treturn \"\", fmt.Errorf(\"content template [%s] is not a regular file\", templatePath)\n\t}\n\tif !gulu.File.IsSubPath(realRoot, realPath) {\n\t\treturn \"\", errors.New(\"content template path is outside templates directory\")\n\t}\n\treturn realPath, nil\n}","sourceCodeStart":700,"sourceCodeEnd":736,"githubUrl":"https://github.com/siyuan-note/siyuan/blob/251596fc0de2f9528c00c224252fd073a99973f4/kernel/model/template.go#L700-L736","documentation":"Returned by resolveDocContentTemplatePath (template.go:718) when the resolved absolute path does not exist on disk (filelock.IsExist(absPath) returns false). The path passed all structural and sub-path guards but no file is present at that location.","triggerScenarios":"A document references a content template file that was deleted, moved, or never created; the templates directory was migrated/renamed; the path has a typo or wrong extension; the workspace data dir changed.","commonSituations":"Template file deleted by the user or a sync conflict; referencing a template by a name that does not match the actual file; workspace moved so <data>/templates/ no longer contains the expected file; case-sensitivity mismatch on case-sensitive filesystems.","solutions":["Confirm the template file exists under <data>/templates/ with the exact name and extension referenced.","On case-sensitive filesystems (Linux), match the filename casing exactly.","If the template was renamed, update the document's content-template path to the new name.","Re-download/recreate the template if a sync operation removed it."],"exampleFix":"// before — file missing or wrong case\nresolveDocContentTemplatePath(\"Diary.md\")  // actual file is diary.md\n\n// after — exact filename\nresolveDocContentTemplatePath(\"diary.md\")","handlingStrategy":"validation","validationCode":"import \"path/filepath\"\nimport \"filelock\"\n\nfunc templateFileExists(p string) bool {\n    abs := filepath.Join(util.DataDir, \"templates\", filepath.Clean(filepath.FromSlash(p)))\n    return filelock.IsExist(abs)\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Confirm the template file exists with exact casing before referencing it.","On case-sensitive filesystems, match the filename case precisely.","After sync operations, verify referenced template files survived."],"tags":["template","filesystem","not-found","validation"],"backgroundTag":null,"analyzedSha":"251596fc0de2f9528c00c224252fd073a99973f4","analyzedAt":"2026-08-12T21:18:37.123Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}