siyuan-note/siyuan · error

date value is missing

Error message

date value is missing

What it means

normalizeNewItemTemplateValue for KeyTypeDate requires value.Date != nil — the Date sub-struct holds the timestamp and its formatted content. A Static-mode value on a Date column that omits the Date pointer is rejected; for auto-time behavior use NewItemFieldValueCurrentTime instead.

Source

Thrown at kernel/av/new_item_template.go:371

	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)
			}
		}
		if KeyTypeSelect == key.Type && 1 < len(selections) {
			selections = selections[:1]
		}
		value.MSelect = selections
		value.Text, value.Number, value.Date, value.URL, value.Email, value.Phone, value.MAsset, value.Checkbox, value.Relation = nil, nil, nil, nil, nil, nil, nil, nil, nil
	case KeyTypeURL:
		if nil == value.URL {
			return nil, errors.New("URL value is missing")
		}

View on GitHub (pinned to 251596fc0d)

Solutions

  1. Set Value.Date = &av.ValueDate{Content: <timestamp>, IsNotDuration: ...} for an explicit date.
  2. If you want creation-time auto-fill, switch fieldValue.Mode to NewItemFieldValueCurrentTime instead.
  3. Match the Value sub-pointer to key.Type exactly.

Example fix

// before
&av.NewItemFieldValue{Mode: av.NewItemFieldValueStatic, Value: &av.Value{}}
// after
&av.NewItemFieldValue{Mode: av.NewItemFieldValueCurrentTime}
Defensive patterns

Strategy: type-guard

Validate before calling

if key.Type == av.KeyTypeDate && value.Date == nil {
    // either supply an explicit date or switch to CurrentTime mode
    return errors.New("date value is missing; use CurrentTime mode or supply Value.Date")
}

Type guard

func hasDateValue(v *av.Value) bool { return v != nil && v.Date != nil }

Prevention

When it happens

Trigger: Static mode on a Date column but Value.Date is nil; client intended auto-time but used Static with an empty value; type mismatch in an import.

Common situations: Partial Value from a client; confusion between Static (explicit date) and CurrentTime (auto-fill) modes.

Related errors


AI-assisted analysis of siyuan-note/siyuan@251596fc0d (2026-08-12). Data as JSON: /api/errors/a8f8288c1432ab2f. Report an issue: GitHub.