{"record":{"id":"a43dc7d60f324ee9","repo":"siyuan-note/siyuan","slug":"new-item-template-field-s-current-time-value-is","errorCode":null,"errorMessage":"new item template field [%s] current time value is invalid","messagePattern":"new item template field \\[(.+?)\\] current time value is invalid","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"kernel/model/attribute_view_new_item.go","lineNumber":592,"sourceCode":"\tif \"\" == renderedPath || strings.HasSuffix(renderedPath, \"/\") {\n\t\treturn \"\"\n\t}\n\treturn normalizeDocTitle(path.Base(renderedPath))\n}\n\nfunc resolveNewItemFieldValues(attrView *av.AttributeView, itemTemplate *av.NewItemTemplate, createdAt time.Time,\n\tcarrierBoxID string) (ret map[string]*av.Value, err error) {\n\tret = map[string]*av.Value{}\n\tfor keyID, fieldValue := range itemTemplate.FieldValues {\n\t\tkey, getErr := attrView.GetKey(keyID)\n\t\tif nil != getErr || nil == key {\n\t\t\treturn nil, fmt.Errorf(\"new item template field [%s] not found\", keyID)\n\t\t}\n\t\tvar value *av.Value\n\t\tswitch fieldValue.Mode {\n\t\tcase av.NewItemFieldValueCurrentTime:\n\t\t\tif av.KeyTypeDate != key.Type {\n\t\t\t\treturn nil, fmt.Errorf(\"new item template field [%s] current time value is invalid\", keyID)\n\t\t\t}\n\t\t\tisNotTime := true\n\t\t\tif nil != key.Date {\n\t\t\t\tisNotTime = !key.Date.FillSpecificTime\n\t\t\t}\n\t\t\tvalue = &av.Value{Type: av.KeyTypeDate, Date: av.NewFormattedValueDate(createdAt.UnixMilli(), 0, av.DateFormatNone, isNotTime, false)}\n\t\tcase av.NewItemFieldValueStatic:\n\t\t\tif nil == fieldValue.Value || fieldValue.Value.Type != key.Type {\n\t\t\t\treturn nil, fmt.Errorf(\"new item template field [%s] value is invalid\", keyID)\n\t\t\t}\n\t\t\tvalue = fieldValue.Value.Clone()\n\t\t\tif av.KeyTypeRelation == key.Type {\n\t\t\t\tfilterNewItemTemplateRelationValue(attrView, key, value, carrierBoxID)\n\t\t\t\tif nil == value.Relation || 0 == len(value.Relation.BlockIDs) {\n\t\t\t\t\tcontinue\n\t\t\t\t}\n\t\t\t}\n\t\tdefault:","sourceCodeStart":574,"sourceCodeEnd":610,"githubUrl":"https://github.com/siyuan-note/siyuan/blob/9f775e8a12daef8255556097396f9b2739078892/kernel/model/attribute_view_new_item.go#L574-L610","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Change the column type back to date, or edit the template so this field uses static text or no value","Remove the FieldValues entry for that key if auto-filling is no longer wanted","Recreate the template against the current column types"],"exampleFix":"// before\nFieldValues: map[string]*av.NewItemFieldValue{ textKeyID: {Mode: av.NewItemFieldValueCurrentTime} }\n// after\nFieldValues: map[string]*av.NewItemFieldValue{ dateKeyID: {Mode: av.NewItemFieldValueCurrentTime} }","handlingStrategy":"validation","validationCode":"if fv.Mode == av.NewItemFieldValueCurrentTime {\n    if key, err := attrView.GetKey(keyID); err != nil || key.Type != av.KeyTypeDate {\n        return fmt.Errorf(\"current-time mode requires a date field: %s\", keyID)\n    }\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Only assign current-time mode to date-type columns","Re-validate templates after changing column types","Prefer static values for non-date fields"],"tags":["attribute-view","type-mismatch","go-kernel"],"backgroundTag":"type-mismatch","analyzedSha":"9f775e8a12daef8255556097396f9b2739078892","analyzedAt":"2026-09-19T03:17:15.984Z","contentChangedAt":"2026-09-19T03:17:15.984Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}