siyuan-note/siyuan · error
new item template field
Error message
new item template field [%s] not found
What it means
resolveNewItemFieldValues materializes each template FieldValues entry into a concrete av.Value. Before evaluating a field's mode it looks the field up by key ID via attrView.GetKey; if the key is missing (or lookup errors), the template references a field that no longer exists in the database and creation aborts with this error. This is a template-vs-schema consistency check.
Solutions
- Edit the new-item template and remove the entry for the missing field key from its FieldValues
- Re-add a column with a matching key, or recreate the template so all referenced keys exist
- After sync-related drift, reload the database so the .av reflects the current schema, then re-check the template
Example fix
// before
template.FieldValues["20240101120000-deletedkey"] = &av.NewItemFieldValue{...}
// after: reference only existing keys
if _, err := attrView.GetKey(keyID); err == nil {
template.FieldValues[keyID] = &av.NewItemFieldValue{...}
} Defensive patterns
Strategy: validation
Validate before calling
for keyID := range tpl.FieldValues {
if _, err := attrView.GetKey(keyID); err != nil {
return fmt.Errorf("template references missing field %s", keyID)
}
} Prevention
- Prune template FieldValues whenever a column is deleted
- Never copy template key IDs across databases
- After sync, reload the database before using stored templates
When it happens
Trigger: createAttributeViewItem with a template whose FieldValues map contains a keyID that was deleted from the attribute view (column removed), or a key ID from a different database pasted into the template config.
Common situations: Deleting an attribute-view column without cleaning templates that fill it; copying template JSON between databases with different key IDs; sync merging where the column was removed on another device.
Understand the failure class
Background: Record Not Found Errors: "not found", RecordNotFound, and "was not found" — what they mean and how to fix them — this error's family across 28 libraries.
Related errors
- bind attribute view item
- clone attribute view item failed
- clone attribute view item
- invalid create attribute view item documents save mode
- new attribute view item document in an encrypted notebook…
AI-assisted analysis of siyuan-note/siyuan@9f775e8a12 (2026-09-19).
Data as JSON: /api/errors/b3e58ecd6286dac0.
Report an issue: GitHub.
Appendix: source
Thrown at kernel/model/attribute_view_new_item.go:586
parent = "/" + parent
}
return parent
}
func newItemTitleFromPath(renderedPath string) string {
if "" == renderedPath || strings.HasSuffix(renderedPath, "/") {
return ""
}
return normalizeDocTitle(path.Base(renderedPath))
}
func resolveNewItemFieldValues(attrView *av.AttributeView, itemTemplate *av.NewItemTemplate, createdAt time.Time,
carrierBoxID string) (ret map[string]*av.Value, err error) {
ret = map[string]*av.Value{}
for keyID, fieldValue := range itemTemplate.FieldValues {
key, getErr := attrView.GetKey(keyID)
if nil != getErr || nil == key {
return nil, fmt.Errorf("new item template field [%s] not found", keyID)
}
var value *av.Value
switch fieldValue.Mode {
case av.NewItemFieldValueCurrentTime:
if av.KeyTypeDate != key.Type {
return nil, fmt.Errorf("new item template field [%s] current time value is invalid", keyID)
}
isNotTime := true
if nil != key.Date {
isNotTime = !key.Date.FillSpecificTime
}
value = &av.Value{Type: av.KeyTypeDate, Date: av.NewFormattedValueDate(createdAt.UnixMilli(), 0, av.DateFormatNone, isNotTime, false)}
case av.NewItemFieldValueStatic:
if nil == fieldValue.Value || fieldValue.Value.Type != key.Type {
return nil, fmt.Errorf("new item template field [%s] value is invalid", keyID)
}
value = fieldValue.Value.Clone()
if av.KeyTypeRelation == key.Type {View on GitHub (pinned to 9f775e8a12)