{"record":{"id":"5d26a739f1e125db","repo":"siyuan-note/siyuan","slug":"fmt-errorf-conf-language-44-err-error","errorCode":null,"errorMessage":"fmt.Errorf(Conf.Language(44), err.Error())","messagePattern":"fmt\\.Errorf\\(Conf\\.Language\\(44\\), err\\.Error\\(\\)\\)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"kernel/model/template_doc_tree_render.go","lineNumber":79,"sourceCode":"\n\tpreviousAllowCreation := collector.allowCreation\n\tcollector.allowCreation = false\n\tdefer func() {\n\t\tcollector.allowCreation = previousAllowCreation\n\t}()\n\n\tbuf := &bytes.Buffer{}\n\tbuf.Grow(4096)\n\tdataModel := templateDocTreeDataModel(node)\n\tif \"\" != node.Define {\n\t\tif nil == rootTemplate.Lookup(node.Define) {\n\t\t\treturn nil, fmt.Errorf(\"child template definition [%s] not found\", node.Define)\n\t\t}\n\t\tif err := validateTemplateCallGraph(rootTemplate, node.Define); nil != err {\n\t\t\treturn nil, err\n\t\t}\n\t\tif err := rootTemplate.ExecuteTemplate(buf, node.Define, dataModel); nil != err {\n\t\t\treturn nil, fmt.Errorf(Conf.Language(44), err.Error())\n\t\t}\n\t\treturn buf.Bytes(), nil\n\t}\n\n\tchildPath, err := resolveTemplatePackageFile(collector.templatePath, node.Template)\n\tif nil != err {\n\t\treturn nil, err\n\t}\n\tcontent, err := os.ReadFile(childPath)\n\tif nil != err {\n\t\treturn nil, err\n\t}\n\tchildTemplate := template.New(\"\").Delims(\".action{\", \"}\").Funcs(funcs)\n\tchildTemplate, err = childTemplate.Parse(string(content))\n\tif nil != err {\n\t\treturn nil, fmt.Errorf(Conf.Language(44), err.Error())\n\t}\n\tif err = validateTemplateCallGraph(childTemplate, childTemplate.Name()); nil != err {","sourceCodeStart":61,"sourceCodeEnd":97,"githubUrl":"https://github.com/siyuan-note/siyuan/blob/9f775e8a12daef8255556097396f9b2739078892/kernel/model/template_doc_tree_render.go#L61-L97","documentation":"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.","triggerScenarios":"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.","commonSituations":"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).","solutions":["Read the appended err.Error() text in the message; it names the exact template, line, and pipeline that failed","Fix the pipeline expression in the template definition body that the error points to","Verify any custom functions used exist in the registered FuncMap (funcs) passed to the template","Test the template standalone by executing it with sample data before installing it as a SiYuan template"],"exampleFix":"// before (template body)\n{{.Title | upper}}\n// after (upper is not in the kernel FuncMap)\n{{.Title}}","handlingStrategy":"try-catch","validationCode":"if rootTemplate.Lookup(node.Define) == nil { return fmt.Errorf(\"definition %q missing\", node.Define) }","typeGuard":null,"tryCatchPattern":"if err := rootTemplate.ExecuteTemplate(buf, node.Define, data); err != nil { return fmt.Errorf(\"template render failed: %w\", err) }","preventionTips":["Test each {{define}} block with sample data before packaging","Only reference functions present in the kernel FuncMap","Keep pipelines simple; avoid deep chained expressions"],"tags":["template","go","text-template","execution"],"backgroundTag":"template-execution-failed","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"}