{"record":{"id":"fb7170d8721c3e5b","repo":"siyuan-note/siyuan","slug":"new-item-template-field-s-type-s-is-not-edit","errorCode":null,"errorMessage":"new item template field [%s] type [%s] is not editable","messagePattern":"new item template field \\[(.+?)\\] type \\[(.+?)\\] is not editable","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"kernel/av/new_item_template.go","lineNumber":314,"sourceCode":"\t\treturn ret[i].KeyID < ret[j].KeyID\n\t})\n\treturn\n}\n\nfunc (av *AttributeView) normalizeNewItemTemplateFieldValues(itemTemplate *NewItemTemplate) error {\n\tif 0 == len(itemTemplate.FieldValues) {\n\t\titemTemplate.FieldValues = nil\n\t\treturn nil\n\t}\n\n\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)","sourceCodeStart":296,"sourceCodeEnd":332,"githubUrl":"https://github.com/siyuan-note/siyuan/blob/9f775e8a12daef8255556097396f9b2739078892/kernel/av/new_item_template.go#L296-L332","documentation":"Template field values are only allowed for key types considered editable (checked by isNewItemTemplateEditableKeyType, e.g. text, number, date, select, URL, etc.). If a FieldValues entry resolves to a key whose type is not editable — such as a computed/rollup/created/updated or template field — the configuration is rejected.","triggerScenarios":"Calling SetNewItemTemplates with FieldValues targeting a key whose Type fails isNewItemTemplateEditableKeyType, e.g. a template/rollup/created-time field that cannot have pre-filled values.","commonSituations":"Pointing a new-item template at an auto-generated or read-only field; a key's type changed after the template was configured (field converted to a non-editable type); building configs programmatically without checking key type.","solutions":["Remove the non-editable key from the template's FieldValues map","Check the key's Type via av.GetKey(keyID) and only include keys accepted by isNewItemTemplateEditableKeyType","If the field type changed, recreate the template config against a suitable editable field"],"exampleFix":"// before\nif _, err := av.GetKey(rollupKeyID); err == nil {\n\ttemplate.FieldValues[rollupKeyID] = fieldValue // rollup is not editable\n}\n// after\nif key, err := av.GetKey(textKeyID); err == nil && isNewItemTemplateEditableKeyType(key.Type) {\n\ttemplate.FieldValues[textKeyID] = fieldValue\n}\nerr := av.SetNewItemTemplates(config)","handlingStrategy":"validation","validationCode":"if key, err := av.GetKey(keyID); err != nil || !isNewItemTemplateEditableKeyType(key.Type) {\n\tdelete(template.FieldValues, keyID)\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Check isNewItemTemplateEditableKeyType (or the key's Type) before adding any FieldValues entry","Re-validate templates after a field's type is changed in the database"],"tags":["attribute-view","validation","type-restriction"],"backgroundTag":"incompatible-source-type","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"}