siyuan-note/siyuan · error
child template [ ] is not a regular file
Error message
child template [%s] is not a regular file
What it means
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.
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
Example fix
// before: templates/pkg/sub (a directory) referenced as child template // after: rename the directory or point the reference to templates/pkg/sub.md (a regular file)
Defensive patterns
Strategy: validation
Validate before calling
const stat = await statIfRegular(path)
function isRegularFile(info) { return info && info.isFile() } Type guard
function isRegularFileInfo(info) { return info !== null && info.isFile(); } Try / catch
try { renderChild(relPath) } catch (e) { if (String(e).includes('is not a regular file')) { fixPackageEntry(relPath) } else { throw e } } Prevention
- 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
When it happens
Trigger: 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).
Common situations: 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.
Understand the failure class
Background: "File not found" and ENOENT errors: why libraries can't find a file that should exist — this error's family across 50 libraries.
Related errors
- path escapes templates dir
- access to sensitive workspace file is forbidden
- invalid template path
- Obsidian Vault is unreadable
- symlink escapes workspace
AI-assisted analysis of siyuan-note/siyuan@9f775e8a12 (2026-09-19).
Data as JSON: /api/errors/5155e8039d53f768.
Report an issue: GitHub.
Appendix: source
Thrown at kernel/model/template_doc_tree.go:428
packageRoot := templatesRoot
if 1 < len(parts) {
packageRoot = filepath.Join(templatesRoot, parts[0])
}
absPath := filepath.Join(packageRoot, cleanPath)
if !gulu.File.IsSubPath(packageRoot, absPath) || !filelock.IsExist(absPath) {
return "", fmt.Errorf("child template [%s] not found in the current template package", relativePath)
}
realRoot, err := filepath.EvalSymlinks(packageRoot)
if nil != err {
return "", err
}
realPath, err := filepath.EvalSymlinks(absPath)
if nil != err {
return "", err
}
info, err := os.Stat(realPath)
if nil != err || !info.Mode().IsRegular() {
return "", fmt.Errorf("child template [%s] is not a regular file", relativePath)
}
if !gulu.File.IsSubPath(realRoot, realPath) {
return "", errors.New("child template path is outside the current template package")
}
return realPath, nil
}
func templateDocTreeDataModel(node *TemplateDocTreeNode) map[string]string {
return map[string]string{
"title": node.Title,
"id": node.ID,
"parentID": node.ParentID,
"rootID": node.RootID,
"hPath": node.HPath,
"name": "",
"alias": "",
}
}View on GitHub (pinned to 9f775e8a12)