siyuan-note/siyuan · error
template source is too large
Error message
template source is too large
What it means
templateFileRevision enforces maxTemplateSourceSize on single template files before reading them into the revision hash; exceeding the cap returns this error. The limit protects memory and hashing cost when templates grow unexpectedly large.
Solutions
- Shrink the template file — move large assets out and reference them instead
- Split the content into multiple smaller templates
- Remove non-template files from the templates directory
Example fix
# before: templates/huge.md contains a 100MB embedded attachment # after: templates/huge.md links to the asset stored outside the template body
Defensive patterns
Strategy: validation
Validate before calling
if info, err := os.Stat(p); err == nil && info.Size() > maxTemplateSourceSize { /* refuse before calling */ } Prevention
- Keep templates small; externalize large assets
- Monitor the templates directory for accidentally dumped large files
When it happens
Trigger: ManageTemplateFiles computing a revision for a template file whose size exceeds maxTemplateSourceSize.
Common situations: Pasting huge documents as templates, template files accidentally containing embedded base64 assets or exported data, or a log/data file dropped into the templates folder.
Understand the failure class
Background: "File too large" / "file size exceeds limit" errors: why libraries cap file sizes and how to fix them — this error's family across 46 libraries.
Related errors
- invalid template source file
- boot appearance package is too large
- cannot write a template directory
- content template path is outside templates directory
- content template [ ] is not a regular file
AI-assisted analysis of siyuan-note/siyuan@9f775e8a12 (2026-09-19).
Data as JSON: /api/errors/172b6c0adb710d11.
Report an issue: GitHub.
Appendix: source
Thrown at kernel/model/template_manage.go:141
h := sha256.New()
if info.IsDir() {
err = fs.WalkDir(root.FS(), p, func(name string, entry fs.DirEntry, walkErr error) error {
if walkErr != nil {
return walkErr
}
stat, statErr := entry.Info()
if statErr != nil {
return statErr
}
if stat.Mode()&os.ModeSymlink != 0 {
return errors.New("template directory contains a symbolic link")
}
fmt.Fprintf(h, "%s\x00%d\x00%d\x00%d\n", name, stat.Size(), stat.ModTime().UnixNano(), stat.Mode())
return nil
})
} else {
if info.Size() > maxTemplateSourceSize {
return "", errors.New("template source is too large")
}
var content []byte
content, err = root.ReadFile(p)
h.Write(content)
}
return fmt.Sprintf("%x", h.Sum(nil)), err
}
func readTemplateSource(root *os.Root, p string) (string, error) {
info, err := root.Stat(p)
if err != nil {
return "", err
}
if !info.Mode().IsRegular() || info.Size() > maxTemplateSourceSize {
return "", errors.New("invalid template source file")
}
content, err := root.ReadFile(p)
if err != nil {View on GitHub (pinned to 9f775e8a12)