siyuan-note/siyuan · error
new item template field
Error message
new item template field [%s] value is invalid
What it means
For mode NewItemFieldValueStatic, the template must supply a non-nil Value whose Type exactly matches the target key's type. If Value is nil or the types disagree, resolveNewItemFieldValues rejects the field with this error, because it cannot safely clone/store a value of the wrong type into the column.
Solutions
- Edit the template and provide a static value object whose Type matches the column type
- If the column type changed, rewrite the static value with the new type (e.g. av.NewValueText) or switch the field to current-time mode
- Remove the FieldValues entry if the field should be left empty
Example fix
// before
&av.NewItemFieldValue{Mode: av.NewItemFieldValueStatic, Value: nil}
// after
&av.NewItemFieldValue{Mode: av.NewItemFieldValueStatic, Value: av.NewValueText("todo")} Defensive patterns
Strategy: validation
Validate before calling
if fv.Mode == av.NewItemFieldValueStatic {
if fv.Value == nil || fv.Value.Type != key.Type {
return fmt.Errorf("static value missing or wrong type for %s", keyID)
}
} Prevention
- Always construct static values with the typed constructors (av.NewValueText, etc.)
- Re-author static values after any column type change
- Validate template JSON before persisting it to the .av file
When it happens
Trigger: createAttributeViewItem with a template whose static FieldValues entry has Value: nil, or a value typed e.g. KeyTypeText for a KeyTypeNumber key (fieldValue.Value.Type != key.Type).
Common situations: Hand-written or plugin-generated template JSON missing the Value object; column type changed after the static value was authored; copying templates across databases with mismatched key types.
Understand the failure class
Background: "Must be a positive integer", "Invalid value", "Unsupported": the invalid-argument-value error family, when a library rejects the value you pass — this error's family across 35 libraries.
Related errors
- new item template field
- bind attribute view item
- block [ ] is not an instance of attribute view [ ]
- clone attribute view item failed
- clone attribute view item
AI-assisted analysis of siyuan-note/siyuan@9f775e8a12 (2026-09-19).
Data as JSON: /api/errors/1f13b3972fc4bb1c.
Report an issue: GitHub.
Appendix: source
Thrown at kernel/model/attribute_view_new_item.go:601
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 {
filterNewItemTemplateRelationValue(attrView, key, value, carrierBoxID)
if nil == value.Relation || 0 == len(value.Relation.BlockIDs) {
continue
}
}
default:
return nil, fmt.Errorf("new item template field [%s] value mode is invalid", keyID)
}
ret[keyID] = value
}
return
}
func filterNewItemTemplateRelationValue(attrView *av.AttributeView, key *av.Key, value *av.Value,
carrierBoxID string) {View on GitHub (pinned to 9f775e8a12)