{"record":{"id":"21cd9489ff1065d1","repo":"siyuan-note/siyuan","slug":"conf-language-44-err-error","errorCode":null,"errorMessage":"Conf.Language(44), err.Error()","messagePattern":"Conf\\.Language\\(44\\), err\\.Error\\(\\)","errorType":"error_code","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/8641553a1f07374001902d3ce773285db1292b2d/kernel/model/template_doc_tree_render.go#L61-L97","documentation":"This is the user-facing wrapper applied when rootTemplate.ExecuteTemplate fails while executing a child template referenced by node.Define. Conf.Language(44) supplies a localized 'template execution failed' message and the underlying Go text/template runtime error is appended, so the real cause (bad pipeline, missing field, nil pointer in data, function error) is inside the wrapped message.","triggerScenarios":"Executing a validly defined child template with templateDocTreeDataModel(node) as data raises a runtime template error: calling a function with wrong argument types, dereferencing a missing map key/field, a template function returning an error, or wrong number of arguments in an action.","commonSituations":"Template actions referencing data fields that don't exist on the node data model; custom template funcs (registered in funcs) erroring on nil input; syntax valid at parse time but failing at execution (e.g. index out of range on a slice).","solutions":["Read the wrapped inner error after the localized prefix to find the failing action/line","Check that all fields/functions referenced by the define exist in templateDocTreeDataModel and the funcs map","Guard possibly-missing data with {{if ...}} or default functions in the template","Test the define standalone with representative node data to reproduce the runtime error"],"exampleFix":"// before: unguarded missing field\n.action{.SomeNested.Value}\n// after\n.action{if .SomeNested}.action{.SomeNested.Value}{end}","handlingStrategy":"try-catch","validationCode":"// pre-check: ensure referenced fields exist on the data model\ntyp nodeModel struct{ Title string; Items []string }\n// in template use only fields present on templateDocTreeDataModel","typeGuard":null,"tryCatchPattern":"content, err := rootTemplate.ExecuteTemplate(buf, name, data)\nif err != nil {\n\treturn fmt.Errorf(\"template %q execution failed: %w\", name, err)\n}","preventionTips":["Guard optional fields with {{if}} before dereferencing them","Test every define with representative node data before deployment","Keep template funcs total (never return errors on nil input); nil-check arguments inside funcs"],"tags":["go","template","execution","i18n"],"backgroundTag":"template-execution-failed","analyzedSha":"8641553a1f07374001902d3ce773285db1292b2d","analyzedAt":"2026-09-11T16:08:28.414Z","contentChangedAt":"2026-09-11T16:08:28.414Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}