{"record":{"id":"a94aabe9a0663313","repo":"siyuan-note/siyuan","slug":"template-directory-contains-a-symbolic-link","errorCode":null,"errorMessage":"template directory contains a symbolic link","messagePattern":"template directory contains a symbolic link","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"kernel/model/template_manage.go","lineNumber":134,"sourceCode":"}\n\nfunc templateFileRevision(root *os.Root, p string) (string, error) {\n\tinfo, err := root.Stat(p)\n\tif err != nil {\n\t\treturn \"\", err\n\t}\n\th := sha256.New()\n\tif info.IsDir() {\n\t\terr = fs.WalkDir(root.FS(), p, func(name string, entry fs.DirEntry, walkErr error) error {\n\t\t\tif walkErr != nil {\n\t\t\t\treturn walkErr\n\t\t\t}\n\t\t\tstat, statErr := entry.Info()\n\t\t\tif statErr != nil {\n\t\t\t\treturn statErr\n\t\t\t}\n\t\t\tif stat.Mode()&os.ModeSymlink != 0 {\n\t\t\t\treturn errors.New(\"template directory contains a symbolic link\")\n\t\t\t}\n\t\t\tfmt.Fprintf(h, \"%s\\x00%d\\x00%d\\x00%d\\n\", name, stat.Size(), stat.ModTime().UnixNano(), stat.Mode())\n\t\t\treturn nil\n\t\t})\n\t} else {\n\t\tif info.Size() > maxTemplateSourceSize {\n\t\t\treturn \"\", errors.New(\"template source is too large\")\n\t\t}\n\t\tvar content []byte\n\t\tcontent, err = root.ReadFile(p)\n\t\th.Write(content)\n\t}\n\treturn fmt.Sprintf(\"%x\", h.Sum(nil)), err\n}\n\nfunc readTemplateSource(root *os.Root, p string) (string, error) {\n\tinfo, err := root.Stat(p)\n\tif err != nil {","sourceCodeStart":116,"sourceCodeEnd":152,"githubUrl":"https://github.com/siyuan-note/siyuan/blob/9f775e8a12daef8255556097396f9b2739078892/kernel/model/template_manage.go#L116-L152","documentation":"While hashing a template directory for revision, templateFileRevision walks its entries and aborts with this error if any contained entry is a symbolic link. Directories under template management must contain only real files so revision fingerprints and packaging stay trustworthy.","triggerScenarios":"ManageTemplateFiles computing a revision over a template package directory that contains a symlinked file (or symlinked child) anywhere in its tree.","commonSituations":"Dotfile-style setups linking assets into template packages, cloud-drive placeholder links, or shared template folders that use symlinks to deduplicate large assets.","solutions":["Replace each symlink inside the template directory with a real copy of its target","Remove the symlinked entries from the package","Rebuild the package so all assets are physical files"],"exampleFix":"# before: pkg/logo.png -> ../../assets/logo.png (symlink)\n# after\ncp -L ../../assets/logo.png pkg/logo.png  # real file","handlingStrategy":"validation","validationCode":"filepath.WalkDir(dir, func(_ string, d fs.DirEntry, err error) error {\n    if err != nil { return err }\n    if d.Type()&fs.ModeSymlink != 0 { return errors.New(\"symlink found\") }\n    return nil\n})","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Keep template packages free of symlinks","Copy assets physically into packages when distributing templates"],"tags":["filesystem","symlink","templates"],"backgroundTag":"path-traversal-blocked","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"}