{"record":{"id":"0efcecef1d5123d1","repo":"siyuan-note/siyuan","slug":"new-item-template-field-s-current-time-mode-req","errorCode":null,"errorMessage":"new item template field [%s] current time mode requires date type","messagePattern":"new item template field \\[(.+?)\\] current time mode requires date type","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"kernel/av/new_item_template.go","lineNumber":325,"sourceCode":"\tfieldValues := map[string]*NewItemFieldValue{}\n\tfor keyID, fieldValue := range itemTemplate.FieldValues {\n\t\tkey, err := av.GetKey(keyID)\n\t\tif nil != err || nil == key {\n\t\t\treturn fmt.Errorf(\"new item template field [%s] not found\", keyID)\n\t\t}\n\t\tif !isNewItemTemplateEditableKeyType(key.Type) {\n\t\t\treturn fmt.Errorf(\"new item template field [%s] type [%s] is not editable\", keyID, key.Type)\n\t\t}\n\t\tif nil == fieldValue {\n\t\t\tcontinue\n\t\t}\n\t\tif \"\" == fieldValue.Mode {\n\t\t\tfieldValue.Mode = NewItemFieldValueStatic\n\t\t}\n\t\tswitch fieldValue.Mode {\n\t\tcase NewItemFieldValueCurrentTime:\n\t\t\tif KeyTypeDate != key.Type {\n\t\t\t\treturn fmt.Errorf(\"new item template field [%s] current time mode requires date type\", keyID)\n\t\t\t}\n\t\t\tfieldValue.Value = nil\n\t\tcase NewItemFieldValueStatic:\n\t\t\tif nil == fieldValue.Value {\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\tfieldValue.Value, err = normalizeNewItemTemplateValue(fieldValue.Value, key)\n\t\t\tif nil != err {\n\t\t\t\treturn fmt.Errorf(\"new item template field [%s] value is invalid: %w\", keyID, err)\n\t\t\t}\n\t\t\tif KeyTypeSelect == key.Type || KeyTypeMSelect == key.Type {\n\t\t\t\tfor _, selection := range fieldValue.Value.MSelect {\n\t\t\t\t\tif nil != selection && nil == key.GetOption(selection.Content) {\n\t\t\t\t\t\treturn fmt.Errorf(\"new item template field [%s] option [%s] not found\", keyID, selection.Content)\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\tdefault:","sourceCodeStart":307,"sourceCodeEnd":343,"githubUrl":"https://github.com/siyuan-note/siyuan/blob/251596fc0de2f9528c00c224252fd073a99973f4/kernel/av/new_item_template.go#L307-L343","documentation":"fieldValue.Mode is NewItemFieldValueCurrentTime but the bound key's type is not KeyTypeDate. CurrentTime mode writes the wall-clock time at row creation, which is only meaningful for date columns, so the validator refuses it for any other type.","triggerScenarios":"A column was changed from Date to another type after the template was configured; client sets CurrentTime on a non-date field; import with a type/mode mismatch.","commonSituations":"Schema migration that changed column type without re-validating templates; client-side type mismatch; stale cached schema.","solutions":["Use NewItemFieldValueStatic with an explicit value for non-date fields.","If you want auto-time on a Date column, confirm key.Type == KeyTypeDate before setting Mode = CurrentTime.","Re-save the template after any column-type change so the validator can re-check."],"exampleFix":"// before — CurrentTime on a Number column\nFieldValues[\"num-key\"] = &av.NewItemFieldValue{Mode: av.NewItemFieldValueCurrentTime}\n// after\nFieldValues[\"num-key\"] = &av.NewItemFieldValue{Mode: av.NewItemFieldValueStatic, Value: &av.Value{Number: &av.ValueNumber{Content: 0}}}","handlingStrategy":"validation","validationCode":"if fieldValue.Mode == av.NewItemFieldValueCurrentTime && key.Type != av.KeyTypeDate {\n    return fmt.Errorf(\"current time mode requires date type\")\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Only set Mode = CurrentTime on KeyTypeDate columns.","For non-date fields, use Static with an explicit value.","Re-validate templates after a column-type change."],"tags":["av","new-item-template","current-time","date","validation","mode"],"backgroundTag":null,"analyzedSha":"251596fc0de2f9528c00c224252fd073a99973f4","analyzedAt":"2026-08-12T21:18:37.123Z","schemaVersion":2},"datasetVersion":"2026-08-13T04:17:16.726Z"}