{"record":{"id":"5155e8039d53f768","repo":"siyuan-note/siyuan","slug":"child-template-s-is-not-a-regular-file","errorCode":null,"errorMessage":"child template [%s] is not a regular file","messagePattern":"child template \\[(.+?)\\] is not a regular file","errorType":"error_code","errorClass":null,"httpStatus":null,"severity":"error","filePath":"kernel/model/template_doc_tree.go","lineNumber":428,"sourceCode":"\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}\n\nfunc templateDocTreeDataModel(node *TemplateDocTreeNode) map[string]string {\n\treturn map[string]string{\n\t\t\"title\":    node.Title,\n\t\t\"id\":       node.ID,\n\t\t\"parentID\": node.ParentID,\n\t\t\"rootID\":   node.RootID,\n\t\t\"hPath\":    node.HPath,\n\t\t\"name\":     \"\",\n\t\t\"alias\":    \"\",\n\t}\n}","sourceCodeStart":410,"sourceCodeEnd":446,"githubUrl":"https://github.com/siyuan-note/siyuan/blob/8641553a1f07374001902d3ce773285db1292b2d/kernel/model/template_doc_tree.go#L410-L446","documentation":"resolveTemplatePackageFile resolves symlinks (EvalSymlinks), stats the real path, and requires the target to be a regular file. Directories, FIFOs, device files, or broken-stat targets produce this error naming the original relative path. Child templates must be readable regular files.","triggerScenarios":"A child template path inside the package resolves to a directory (e.g. {{childTemplate \"partials\"}} where partials/ is a folder), or to a special file/symlink whose target is not a regular file.","commonSituations":"Template author forgets the file extension and references the containing folder; a package directory named like the template file; a symlink pointing to a directory; packaging scripts accidentally replacing a .md file with a directory during extraction.","solutions":["Point the child template reference at an actual file, not a directory (add the file name/extension)","If a directory was created where the file should be, rename the directory and create the template file","Replace directory symlinks with a direct file reference inside the package","Re-extract or re-download the template package if packaging corrupted the file"],"exampleFix":"// before (template content)\n{{childTemplate \"partials\"}}\n// after\n{{childTemplate \"partials/header.md\"}}","handlingStrategy":"validation","validationCode":"// Go: ensure each referenced child template is a regular file\ninfo, err := os.Stat(filepath.Join(pkgRoot, filepath.FromSlash(ref)))\nisRegular := err == nil && info.Mode().IsRegular()","typeGuard":null,"tryCatchPattern":"if _, err := resolveTemplatePackageFile(root, rel); err != nil && strings.Contains(err.Error(), \"is not a regular file\") {\n    return fmt.Errorf(\"%q resolves to a directory or special file\", rel)\n}","preventionTips":["Reference files with their full name and extension, not the containing folder","Do not name directories the same as expected template files","Avoid symlinks to directories inside template packages","Validate package contents (files not dirs) after extraction or download"],"tags":["template","file-type","template-package","siyuan-kernel"],"backgroundTag":"path-is-not-a-directory","analyzedSha":"8641553a1f07374001902d3ce773285db1292b2d","analyzedAt":"2026-09-11T16:08:28.414Z","contentChangedAt":"2026-09-11T16:08:28.414Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}