{"record":{"id":"7860ac8213294cbc","repo":"siyuan-note/siyuan","slug":"child-template-s-not-found-in-the-current-templ","errorCode":null,"errorMessage":"child template [%s] not found in the current template package","messagePattern":"child template \\[(.+?)\\] not found in the current template package","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"kernel/model/template_doc_tree.go","lineNumber":416,"sourceCode":"\trelativePath = strings.TrimPrefix(filepath.ToSlash(strings.TrimSpace(relativePath)), \"/\")\n\tcleanPath := filepath.Clean(filepath.FromSlash(relativePath))\n\tif \"\" == cleanPath || \".\" == cleanPath || filepath.IsAbs(cleanPath) || \"..\" == cleanPath ||\n\t\tstrings.HasPrefix(cleanPath, \"..\"+string(os.PathSeparator)) {\n\t\treturn \"\", errors.New(\"invalid child template path\")\n\t}\n\ttemplatesRoot := filepath.Clean(filepath.Join(util.DataDir, \"templates\"))\n\trelRootTemplate, err := filepath.Rel(templatesRoot, filepath.Clean(rootTemplatePath))\n\tif nil != err || strings.HasPrefix(relRootTemplate, \"..\"+string(os.PathSeparator)) {\n\t\treturn \"\", errors.New(\"template path is outside templates directory\")\n\t}\n\tparts := strings.Split(filepath.ToSlash(relRootTemplate), \"/\")\n\tpackageRoot := templatesRoot\n\tif 1 < len(parts) {\n\t\tpackageRoot = filepath.Join(templatesRoot, parts[0])\n\t}\n\tabsPath := filepath.Join(packageRoot, cleanPath)\n\tif !gulu.File.IsSubPath(packageRoot, absPath) || !filelock.IsExist(absPath) {\n\t\treturn \"\", fmt.Errorf(\"child template [%s] not found in the current template package\", relativePath)\n\t}\n\trealRoot, err := filepath.EvalSymlinks(packageRoot)\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(\"child template [%s] is not a regular file\", relativePath)\n\t}\n\tif !gulu.File.IsSubPath(realRoot, realPath) {\n\t\treturn \"\", errors.New(\"child template path is outside the current template package\")\n\t}\n\treturn realPath, nil\n}","sourceCodeStart":398,"sourceCodeEnd":434,"githubUrl":"https://github.com/siyuan-note/siyuan/blob/9f775e8a12daef8255556097396f9b2739078892/kernel/model/template_doc_tree.go#L398-L434","documentation":"resolveTemplatePackageFile resolves the package root (the first path segment of the root template under data/templates) and joins the cleaned relative path to it. If the resulting file is not a strict sub-path of the package root or does not exist on disk, the child template reference cannot be satisfied and this error names the missing relative path.","triggerScenarios":"A doc-tree template action references a child template file that does not exist inside the same package directory — wrong filename, wrong extension, file deleted, or a path reaching outside the package root (rejected by IsSubPath).","commonSituations":"Sharing a template package with missing files (e.g. forgot to copy sub/ folder); case-sensitivity mismatches on Linux (Tpl.md vs tpl.md); referencing .md vs .tpl extension wrongly; moving a child out of the package directory.","solutions":["Create or restore the referenced child template file inside the package directory","Fix the relative path/filename (check case and extension) to match the actual file","Keep all child templates within the same package root (first-level directory under data/templates)"],"exampleFix":"// before: file data/templates/my-package/sub/tpl.md missing\n{{child \"sub/tpl.md\"}} // error\n// after: add the file or correct the name\n{{child \"sub/page.md\"}} // data/templates/my-package/sub/page.md exists","handlingStrategy":"validation","validationCode":"abs := filepath.Join(packageRoot, clean)\nif !gulu.File.IsSubPath(packageRoot, abs) || !filelock.IsExist(abs) { /* child missing */ }","typeGuard":null,"tryCatchPattern":"p, err := resolveTemplatePackageFile(root, rel)\nif err != nil && strings.Contains(err.Error(), \"not found in the current template package\") {\n  // create the file or correct the reference path\n}","preventionTips":["Ship complete template packages including all child files","Check filename case and extensions when sharing across OSes","Verify child references resolve after moving or renaming package files"],"tags":["go","template","missing-file"],"backgroundTag":"file-not-found","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"}