{"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":"validation","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/9f775e8a12daef8255556097396f9b2739078892/kernel/model/template_doc_tree.go#L410-L446","documentation":"resolveTemplatePackageFile validates that a child template referenced from a template doc tree resolves, after symlink evaluation, to a regular file inside the template package. This error is thrown when the resolved path exists (or Stat fails) but is not a regular file — e.g. it is a directory, device, or a broken entry. It is a safety check so only real template files are rendered.","triggerScenarios":"A template node references a child template path that points at a directory inside the template package, or the path exists but os.Stat fails after EvalSymlinks (e.g. the symlink target was deleted between checks), or the target is a special file (fifo/socket/device).","commonSituations":"User creates a directory with the same name as the expected template file; a template package is partially copied so a subpath is a folder; a symlink inside the template package points to a directory or dangling target.","solutions":["Check that the referenced child template path is a plain file, not a directory, under data/templates/<package>/","Fix or remove the symlink; EvalSymlinks resolves it and the resolved target must be a regular file","Re-copy the template package so the referenced file exists as a regular file"],"exampleFix":"// before: templates/pkg/sub (a directory) referenced as child template\n// after: rename the directory or point the reference to templates/pkg/sub.md (a regular file)","handlingStrategy":"validation","validationCode":"const stat = await statIfRegular(path)\nfunction isRegularFile(info) { return info && info.isFile() }","typeGuard":"function isRegularFileInfo(info) { return info !== null && info.isFile(); }","tryCatchPattern":"try { renderChild(relPath) } catch (e) { if (String(e).includes('is not a regular file')) { fixPackageEntry(relPath) } else { throw e } }","preventionTips":["Keep template packages as plain files, never directories at template file paths","Avoid symlinks inside data/templates","Validate package layout after copying or downloading a template package"],"tags":["filesystem","template","path-validation"],"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"}