{"record":{"id":"a8f8288c1432ab2f","repo":"siyuan-note/siyuan","slug":"date-value-is-missing","errorCode":null,"errorMessage":"date value is missing","messagePattern":"date value is missing","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"kernel/av/new_item_template.go","lineNumber":371,"sourceCode":"\treturn nil\n}\n\nfunc normalizeNewItemTemplateValue(value *Value, key *Key) (*Value, error) {\n\tvalue = value.Clone()\n\tswitch key.Type {\n\tcase KeyTypeText:\n\t\tif nil == value.Text {\n\t\t\treturn nil, errors.New(\"text value is missing\")\n\t\t}\n\t\tvalue.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\n\tcase KeyTypeNumber:\n\t\tif nil == value.Number {\n\t\t\treturn nil, errors.New(\"number value is missing\")\n\t\t}\n\t\tvalue.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\n\tcase KeyTypeDate:\n\t\tif nil == value.Date {\n\t\t\treturn nil, errors.New(\"date value is missing\")\n\t\t}\n\t\tvalue.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\n\tcase KeyTypeSelect, KeyTypeMSelect:\n\t\tvar selections []*ValueSelect\n\t\tfor _, selection := range value.MSelect {\n\t\t\tif nil != selection && \"\" != strings.TrimSpace(selection.Content) {\n\t\t\t\tselections = append(selections, selection)\n\t\t\t}\n\t\t}\n\t\tif KeyTypeSelect == key.Type && 1 < len(selections) {\n\t\t\tselections = selections[:1]\n\t\t}\n\t\tvalue.MSelect = selections\n\t\tvalue.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\n\tcase KeyTypeURL:\n\t\tif nil == value.URL {\n\t\t\treturn nil, errors.New(\"URL value is missing\")\n\t\t}","sourceCodeStart":353,"sourceCodeEnd":389,"githubUrl":"https://github.com/siyuan-note/siyuan/blob/251596fc0de2f9528c00c224252fd073a99973f4/kernel/av/new_item_template.go#L353-L389","documentation":"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.","triggerScenarios":"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.","commonSituations":"Partial Value from a client; confusion between Static (explicit date) and CurrentTime (auto-fill) modes.","solutions":["Set Value.Date = &av.ValueDate{Content: <timestamp>, IsNotDuration: ...} for an explicit date.","If you want creation-time auto-fill, switch fieldValue.Mode to NewItemFieldValueCurrentTime instead.","Match the Value sub-pointer to key.Type exactly."],"exampleFix":"// before\n&av.NewItemFieldValue{Mode: av.NewItemFieldValueStatic, Value: &av.Value{}}\n// after\n&av.NewItemFieldValue{Mode: av.NewItemFieldValueCurrentTime}","handlingStrategy":"type-guard","validationCode":"if key.Type == av.KeyTypeDate && value.Date == nil {\n    // either supply an explicit date or switch to CurrentTime mode\n    return errors.New(\"date value is missing; use CurrentTime mode or supply Value.Date\")\n}","typeGuard":"func hasDateValue(v *av.Value) bool { return v != nil && v.Date != nil }","tryCatchPattern":null,"preventionTips":["For auto-fill at creation time, use Mode = NewItemFieldValueCurrentTime instead of Static.","For explicit dates, set Value.Date with a valid timestamp.","Match the Value sub-pointer to key.Type exactly."],"tags":["av","new-item-template","date","value","validation"],"backgroundTag":null,"analyzedSha":"251596fc0de2f9528c00c224252fd073a99973f4","analyzedAt":"2026-08-12T21:18:37.123Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}