siyuan-note/siyuan · error

new item template field

Error message

new item template field [%s] current time value is invalid

What it means

When a template field value uses mode NewItemFieldValueCurrentTime, resolveNewItemFieldValues requires the target key to be a date field (av.KeyTypeDate). Filling the current time into a text, number, or relation column is not supported, so it returns this error naming the offending key. It is a mode/key-type compatibility check.

Solutions

  1. Change the column type back to date, or edit the template so this field uses static text or no value
  2. Remove the FieldValues entry for that key if auto-filling is no longer wanted
  3. Recreate the template against the current column types

Example fix

// before
FieldValues: map[string]*av.NewItemFieldValue{ textKeyID: {Mode: av.NewItemFieldValueCurrentTime} }
// after
FieldValues: map[string]*av.NewItemFieldValue{ dateKeyID: {Mode: av.NewItemFieldValueCurrentTime} }
Defensive patterns

Strategy: validation

Validate before calling

if fv.Mode == av.NewItemFieldValueCurrentTime {
    if key, err := attrView.GetKey(keyID); err != nil || key.Type != av.KeyTypeDate {
        return fmt.Errorf("current-time mode requires a date field: %s", keyID)
    }
}

Prevention

When it happens

Trigger: A new-item template FieldValues entry with Mode: av.NewItemFieldValueCurrentTime pointing at a key whose Type is not av.KeyTypeDate (e.g. text or number column), encountered in createAttributeViewItem.

Common situations: Column type changed from date to text after the template was configured with 'fill current time'; template copied to another database where the same-named column has a different type.

Understand the failure class

Background: Type mismatch errors: IllegalArgumentException, TypeError and type guards across 150 open-source libraries — this error's family across 150 libraries.

Related errors


AI-assisted analysis of siyuan-note/siyuan@9f775e8a12 (2026-09-19). Data as JSON: /api/errors/a43dc7d60f324ee9. Report an issue: GitHub.

Appendix: source

Thrown at kernel/model/attribute_view_new_item.go:592

	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 {
				filterNewItemTemplateRelationValue(attrView, key, value, carrierBoxID)
				if nil == value.Relation || 0 == len(value.Relation.BlockIDs) {
					continue
				}
			}
		default:

View on GitHub (pinned to 9f775e8a12)