siyuan-note/siyuan · error
new item template field [%s] value is invalid: %w
Error message
new item template field [%s] value is invalid: %w
What it means
Wrapper around normalizeNewItemTemplateValue failures for Static-mode values. The wrapped error (%w) identifies the concrete problem: one of the per-type 'X value is missing' errors (text/number/date/URL/email/phone/checkbox/relation), 'invalid asset type', 'invalid relation block ID', or 'unsupported value type'. The field keyID prefixes the wrapped message.
Source
Thrown at kernel/av/new_item_template.go:334
if nil == fieldValue {
continue
}
if "" == fieldValue.Mode {
fieldValue.Mode = NewItemFieldValueStatic
}
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
}View on GitHub (pinned to 251596fc0d)
Solutions
- Read the wrapped error — it names the specific sub-field or constraint that failed (e.g. 'URL value is missing').
- Ensure the Value struct carries the sub-pointer that matches key.Type (see normalizeNewItemTemplateValue, new_item_template.go:356).
- For Relation values, validate every BlockID with ast.IsNodeIDPattern before submitting.
Defensive patterns
Strategy: try-catch
Validate before calling
// Pre-normalize one value to surface the inner error early.
if _, err := normalizeNewItemTemplateValue(value, key); err != nil {
return fmt.Errorf("field [%s] value is invalid: %w", keyID, err)
} Try / catch
err := av.SetNewItemTemplates(config)
if err != nil && strings.Contains(err.Error(), "value is invalid") {
// inspect err for the wrapped cause (missing sub-field, bad relation ID, etc.)
return err
} Prevention
- Read the wrapped error to find the exact sub-field that failed.
- Populate the Value sub-pointer that matches key.Type exactly.
- For Relation values, validate every BlockID with ast.IsNodeIDPattern first.
When it happens
Trigger: Static mode on a field whose Value sub-struct does not match the key type (e.g. key=URL but Value.URL nil); a Relation value containing a malformed block ID; an MAsset value with an unknown asset type.
Common situations: Client sends a partial Value with the wrong sub-field populated; type change after the template was authored; malformed import.
Related errors
- text value is missing
- number value is missing
- date value is missing
- URL value is missing
- new item templates config is nil
AI-assisted analysis of siyuan-note/siyuan@251596fc0d (2026-08-12).
Data as JSON: /api/errors/54b18734aa37387f.
Report an issue: GitHub.