siyuan-note/siyuan · error
text value is missing
Error message
text value is missing
What it means
normalizeNewItemTemplateValue, when handling a KeyTypeText key, requires the Value to carry a non-nil Text payload. A cloned Value with value.Text == nil cannot represent text content, so it returns the sentinel error 'text value is missing', which callers wrap or surface when pruning invalid field values.
Solutions
- Set Value.Text to a &av.ValueText with the desired Content before saving
- Remove the FieldValues entry if no text value is needed
- Verify the key's Type matches the payload you are filling
Example fix
// before
fv.Value = &av.Value{Number: &av.ValueNumber{Content: 1}} // text key
err := av.SetNewItemTemplates(config) // text value is missing
// after
fv.Value = &av.Value{Text: &av.ValueText{Content: "1"}}
err := av.SetNewItemTemplates(config) Defensive patterns
Strategy: validation
Validate before calling
if key.Type == av.KeyTypeText && (fv.Value == nil || fv.Value.Text == nil) {
return fmt.Errorf("text key %s requires a Text payload", keyID)
} Type guard
func hasTextPayload(v *av.Value) bool { return v != nil && v.Text != nil } Prevention
- Match the Value sub-field to the key type before assigning it
- Run PruneInvalidNewItemTemplateFieldValues to drop unusable values instead of failing the whole config
When it happens
Trigger: Calling SetNewItemTemplates (static mode) — or PruneInvalidNewItemTemplateFieldValues — with a Value for a text key where the Text sub-field is nil while some other sub-field (Number, Date, etc.) may be populated instead.
Common situations: Reusing a Value object taken from a number or date field for a text key; constructing &av.Value{} without setting Text; JSON deserialization dropping the Text payload.
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
- number value is missing
- at least one visible view is required
- attribute view custom color index
- attribute view custom color must not be null
AI-assisted analysis of siyuan-note/siyuan@9f775e8a12 (2026-09-19).
Data as JSON: /api/errors/a22d2c0b4a2f08da.
Report an issue: GitHub.
Appendix: source
Thrown at kernel/av/new_item_template.go:361
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()
switch key.Type {
case KeyTypeText:
if nil == value.Text {
return nil, errors.New("text value is missing")
}
value.Number, value.Date, value.MSelect, value.URL, value.Email, value.Phone, value.MAsset, value.Checkbox, value.Relation = nil, nil, nil, nil, nil, nil, nil, nil, nil
case KeyTypeNumber:
if nil == value.Number {
return nil, errors.New("number value is missing")
}
value.Text, value.Date, value.MSelect, value.URL, value.Email, value.Phone, value.MAsset, value.Checkbox, value.Relation = nil, nil, nil, nil, nil, nil, nil, nil, nil
case KeyTypeDate:
if nil == value.Date {
return nil, errors.New("date value is missing")
}
value.Text, value.Number, value.MSelect, value.URL, value.Email, value.Phone, value.MAsset, value.Checkbox, value.Relation = nil, nil, nil, nil, nil, nil, nil, nil, nil
case KeyTypeSelect, KeyTypeMSelect:
var selections []*ValueSelect
for _, selection := range value.MSelect {
if nil != selection && "" != strings.TrimSpace(selection.Content) {
selections = append(selections, selection)
}View on GitHub (pinned to 9f775e8a12)