siyuan-note/siyuan · error
database [ ] template field [ ] rendering failed
Error message
database [%s] template field [%s] rendering failed: %s
What it means
Database (attribute view) template columns are rendered as Go text/template with custom delimiters .action{ } and a function set from filesys.BuiltInTemplateFuncs plus SQL template funcs (compileTemplateField, av.go:182). When a column's content fails to parse or execute, the row records 'database [<av name>] template field [<column name>] rendering failed: <cause>'; the parse error is also logged at warn level. Rendering continues for other rows and the last error is returned.
Solutions
- Open the database named in the error, edit the template column named in the error, and fix the syntax - the <cause> suffix carries the exact template error (e.g. function 'X' not defined)
- Use .action{ } delimiters, not {{ }} - this column type shares the doc template action syntax
- Stick to context that exists on rows: IAL keys such as id, created, updated plus other column values
- If a referenced column was renamed or deleted, update the template - stale references surface as execution errors
Example fix
before (template column content):
.action{.updated
after:
.action{.updated} Defensive patterns
Strategy: validation
Try / catch
Callers of attribute-view rendering (e.g. /api/av endpoints or plugin APIs that render databases) should check the returned error, log it, and degrade gracefully - render remaining columns and show the template column's raw text instead of failing the whole view.
Prevention
- Test new template column content on a scratch row before applying to a large database
- Use .action{ } delimiters - never {{ }} - in database template columns
- Only reference context that exists on rows (id, created, updated, other columns); update templates after renaming referenced columns
- Check the kernel log: the underlying parse error is logged at warn level with the template content
When it happens
Trigger: Template content with syntax errors - unbalanced .action{, stray }, unknown function (.action{SomeFunc}); calling a template function with wrong arity or wrong argument type; referencing fields that do not exist on the row context at execution time; using {{ }} instead of the .action{ } delimiters.
Common situations: Pasting doc-template snippets into a database template column (same syntax family, different available context); renaming a column that another template references; incomplete autocomplete of function names; templates written for a different SiYuan version's function set.
Related errors
- database blocks are not supported by createDocTree templates
- view not found
- attribute view not found
- attribute view [ ] has no available view
- attribute view [ ] has no available visible view
AI-assisted analysis of siyuan-note/siyuan@afa823b6b4 (2026-08-18).
Data as JSON: /api/errors/a6d09254a6faabc9.
Report an issue: GitHub.
Appendix: source
Thrown at kernel/sql/av.go:861
if nil != compileErr {
compileErrCache[value.Template.Content] = compileErr
renderErr = compileErr
} else {
tpl = compiled
}
} else if nil == tpl {
renderErr = compileErrCache[value.Template.Content] // 复用首次解析的错误
}
if nil == renderErr {
content, renderErr = executeTemplateField(tpl, ial, keyValues)
}
if nil != renderErr {
key, _ := attrView.GetKey(value.KeyID)
keyName := ""
if nil != key {
keyName = key.Name
}
err = fmt.Errorf("database [%s] template field [%s] rendering failed: %s", getAttrViewName(attrView), keyName, renderErr)
}
value.Template.Content = content
items[item.GetID()] = append(keyValues, &av.KeyValues{Key: templateKey, Values: []*av.Value{value}})
}
}
return
}
func fillAttributeViewKeyValues(attrView *av.AttributeView, collection av.Collection) {
fieldValues := map[string][]*av.Value{}
for _, item := range collection.GetItems() {
for _, val := range item.GetValues() {
keyID := val.KeyID
fieldValues[keyID] = append(fieldValues[keyID], val)
}
}
for keyID, values := range fieldValues {View on GitHub (pinned to afa823b6b4)