siyuan-note/siyuan · error
new item template field
Error message
new item template field [%s] option [%s] not found
What it means
For select/multi-select keys, after normalizing a static value each selected option content is checked against the key's configured options via key.GetOption. If a selection's content does not match any defined option, the configuration is rejected because template-generated rows may only reference existing options.
Solutions
- Update the selection Content to exactly match an existing option defined on the key
- Add the missing option to the key before saving the template, or remove the stale selection
- Re-derive selectable values from key.GetOptions() instead of hardcoding strings
Example fix
// before
fv.Value = &av.Value{MSelect: []*av.ValueSelect{{Content: "High "}}} // option renamed
err := av.SetNewItemTemplates(config) // option [High ] not found
// after
fv.Value = &av.Value{MSelect: []*av.ValueSelect{{Content: "High"}}} // matches key option
err := av.SetNewItemTemplates(config) Defensive patterns
Strategy: validation
Validate before calling
for _, sel := range fv.Value.MSelect {
if sel != nil && key.GetOption(sel.Content) == nil {
return fmt.Errorf("option %q not defined on key %s", sel.Content, keyID)
}
} Prevention
- Source selectable values from key.GetOptions() rather than hardcoding strings
- Re-validate template selections after renaming or deleting key options
When it happens
Trigger: Calling SetNewItemTemplates with a static FieldValues entry on a KeyTypeSelect/KeyTypeMSelect key whose Value.MSelect contains a selection whose Content is not one of the key's declared options.
Common situations: An option was renamed or deleted after the template stored it; hardcoding option text that differs in case or whitespace from the defined option; copying select values between databases with different option sets.
Understand the failure class
Background: 'Could not be found', 'does not exist', 'not found in database': the resource-not-found family when an ID, slug, key, or URI lookup comes back empty — this error's family across 20 libraries.
Related errors
- at least one visible view is required
- attribute view custom color index
- attribute view custom color must not be null
- attribute view custom colors count exceeds the
- attribute view custom colors must not be empty
AI-assisted analysis of siyuan-note/siyuan@9f775e8a12 (2026-09-19).
Data as JSON: /api/errors/8dc657636dd5a0dd.
Report an issue: GitHub.
Appendix: source
Thrown at kernel/av/new_item_template.go:339
}
switch fieldValue.Mode {
case NewItemFieldValueCurrentTime:
if KeyTypeDate != key.Type {
return fmt.Errorf("new item template field [%s] current time mode requires date type", keyID)
}
fieldValue.Value = nil
case NewItemFieldValueStatic:
if nil == fieldValue.Value {
continue
}
fieldValue.Value, err = normalizeNewItemTemplateValue(fieldValue.Value, key)
if nil != err {
return fmt.Errorf("new item template field [%s] value is invalid: %w", keyID, err)
}
if KeyTypeSelect == key.Type || KeyTypeMSelect == key.Type {
for _, selection := range fieldValue.Value.MSelect {
if nil != selection && nil == key.GetOption(selection.Content) {
return fmt.Errorf("new item template field [%s] option [%s] not found", keyID, selection.Content)
}
}
}
default:
return fmt.Errorf("invalid new item template field value mode [%s]", fieldValue.Mode)
}
fieldValues[keyID] = fieldValue
}
if 0 == len(fieldValues) {
itemTemplate.FieldValues = nil
} else {
itemTemplate.FieldValues = fieldValues
}
return nil
}
func normalizeNewItemTemplateValue(value *Value, key *Key) (*Value, error) {
value = value.Clone()View on GitHub (pinned to 9f775e8a12)