siyuan-note/siyuan · error

fmt.Errorf(Conf.Language(44), err.Error())

Error message

fmt.Errorf(Conf.Language(44), err.Error())

What it means

SiYuan wraps any error produced while executing a named child template definition (text/template ExecuteTemplate) with Conf.Language(44), the localized "template render failed" message. The underlying text/template error (e.g. undefined function call, nil pointer in a pipeline, wrong data field) is appended as %s. This is the kernel's way of reporting that a .action{...} template body failed at execution time, not parse time.

Solutions

  1. Read the appended err.Error() text in the message; it names the exact template, line, and pipeline that failed
  2. Fix the pipeline expression in the template definition body that the error points to
  3. Verify any custom functions used exist in the registered FuncMap (funcs) passed to the template
  4. Test the template standalone by executing it with sample data before installing it as a SiYuan template

Example fix

// before (template body)
{{.Title | upper}}
// after (upper is not in the kernel FuncMap)
{{.Title}}
Defensive patterns

Strategy: try-catch

Validate before calling

if rootTemplate.Lookup(node.Define) == nil { return fmt.Errorf("definition %q missing", node.Define) }

Try / catch

if err := rootTemplate.ExecuteTemplate(buf, node.Define, data); err != nil { return fmt.Errorf("template render failed: %w", err) }

Prevention

When it happens

Trigger: Triggered by renderTemplateDocTreeNodeContent when node.Define is set and rootTemplate.ExecuteTemplate(buf, node.Define, dataModel) returns an error during createDocTree template rendering: e.g. the definition body calls a missing template function, indexes a field absent from the data model, or the pipeline returns an error at runtime.

Common situations: Template authors referencing a funcMap function that does not exist, accessing .Field on data where Field is a map key that is missing, calling a method that returns an error, or data type mismatches (e.g. ranging over a non-iterable value).

Related errors


AI-assisted analysis of siyuan-note/siyuan@9f775e8a12 (2026-09-19). Data as JSON: /api/errors/5d26a739f1e125db. Report an issue: GitHub.

Appendix: source

Thrown at kernel/model/template_doc_tree_render.go:79

	previousAllowCreation := collector.allowCreation
	collector.allowCreation = false
	defer func() {
		collector.allowCreation = previousAllowCreation
	}()

	buf := &bytes.Buffer{}
	buf.Grow(4096)
	dataModel := templateDocTreeDataModel(node)
	if "" != node.Define {
		if nil == rootTemplate.Lookup(node.Define) {
			return nil, fmt.Errorf("child template definition [%s] not found", node.Define)
		}
		if err := validateTemplateCallGraph(rootTemplate, node.Define); nil != err {
			return nil, err
		}
		if err := rootTemplate.ExecuteTemplate(buf, node.Define, dataModel); nil != err {
			return nil, fmt.Errorf(Conf.Language(44), err.Error())
		}
		return buf.Bytes(), nil
	}

	childPath, err := resolveTemplatePackageFile(collector.templatePath, node.Template)
	if nil != err {
		return nil, err
	}
	content, err := os.ReadFile(childPath)
	if nil != err {
		return nil, err
	}
	childTemplate := template.New("").Delims(".action{", "}").Funcs(funcs)
	childTemplate, err = childTemplate.Parse(string(content))
	if nil != err {
		return nil, fmt.Errorf(Conf.Language(44), err.Error())
	}
	if err = validateTemplateCallGraph(childTemplate, childTemplate.Name()); nil != err {

View on GitHub (pinned to 9f775e8a12)