{"record":{"id":"fb155afdcb20505e","repo":"siyuan-note/siyuan","slug":"unsupported-value-type-s","errorCode":null,"errorMessage":"unsupported value type [%s]","messagePattern":"unsupported value type \\[(.+?)\\]","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"kernel/av/new_item_template.go","lineNumber":429,"sourceCode":"\t\tvalue.MAsset = assets\n\t\tvalue.Text, value.Number, value.Date, value.MSelect, value.URL, value.Email, value.Phone, value.Checkbox, value.Relation = nil, nil, nil, nil, nil, nil, nil, nil, nil\n\tcase KeyTypeCheckbox:\n\t\tif nil == value.Checkbox {\n\t\t\treturn nil, errors.New(\"checkbox value is missing\")\n\t\t}\n\t\tvalue.Text, value.Number, value.Date, value.MSelect, value.URL, value.Email, value.Phone, value.MAsset, value.Relation = nil, nil, nil, nil, nil, nil, nil, nil, nil\n\tcase KeyTypeRelation:\n\t\tif nil == value.Relation {\n\t\t\treturn nil, errors.New(\"relation value is missing\")\n\t\t}\n\t\tfor _, blockID := range value.Relation.BlockIDs {\n\t\t\tif !ast.IsNodeIDPattern(blockID) {\n\t\t\t\treturn nil, fmt.Errorf(\"invalid relation block ID [%s]\", blockID)\n\t\t\t}\n\t\t}\n\t\tvalue.Text, value.Number, value.Date, value.MSelect, value.URL, value.Email, value.Phone, value.MAsset, value.Checkbox = nil, nil, nil, nil, nil, nil, nil, nil, nil\n\tdefault:\n\t\treturn nil, fmt.Errorf(\"unsupported value type [%s]\", key.Type)\n\t}\n\tvalue.Block, value.Template, value.Created, value.Updated, value.Rollup = nil, nil, nil, nil, nil\n\tvalue.ID = \"\"\n\tvalue.KeyID = \"\"\n\tvalue.BlockID = \"\"\n\tvalue.Type = key.Type\n\tvalue.IsDetached = false\n\tvalue.CreatedAt = 0\n\tvalue.UpdatedAt = 0\n\tvalue.IsRenderAutoFill = false\n\tif nil != value.Number {\n\t\tvalue.Number.Format = key.NumberFormat\n\t\tvalue.Number.FormattedContent = \"\"\n\t}\n\tif nil != value.Date {\n\t\tvalue.Date.FormattedContent = \"\"\n\t}\n\tif nil != value.Created {","sourceCodeStart":411,"sourceCodeEnd":447,"githubUrl":"https://github.com/siyuan-note/siyuan/blob/251596fc0de2f9528c00c224252fd073a99973f4/kernel/av/new_item_template.go#L411-L447","documentation":"The default case in normalizeNewItemTemplateValue's type switch (kernel/av/new_item_template.go:428-429). It fires when key.Type does not match any handled case (text, number, date, select/mSelect, url, email, phone, mAsset, checkbox, relation). Non-editable types like block, template, created, updated, and rollup fall through to here. Under normal flow, isNewItemTemplateEditableKeyType filters those out before this function is reached, so this error indicates either a bypassed guard or a newly added KeyType not yet covered by the normalizer.","triggerScenarios":"A new-item template FieldValues entry references a key whose type is one of the non-normalizable types (block, template, created, updated, rollup), or a custom/unknown key type string.","commonSituations":"Adding a new KeyType constant to the av package without updating normalizeNewItemTemplateValue's switch; directly calling normalizeNewItemTemplateValue bypassing the editable-key-type filter; corrupted AV data with an unexpected type string.","solutions":["Do not include non-editable field types (block, template, created, updated, rollup) in new-item template FieldValues","If you added a new KeyType, add a corresponding case to the type switch in normalizeNewItemTemplateValue","Remove the offending field from the template and retry"],"exampleFix":"// before: template includes a created-type key\nitemTemplate.FieldValues[createdKeyID] = &av.NewItemFieldValue{Mode: av.NewItemFieldValueStatic, Value: &av.Value{Type: av.KeyTypeCreated}}\n// after: omit non-editable keys from templates\ndelete(itemTemplate.FieldValues, createdKeyID)","handlingStrategy":"validation","validationCode":"func isNormalizableKeyType(keyType av.KeyType) bool {\n    switch keyType {\n    case av.KeyTypeText, av.KeyTypeNumber, av.KeyTypeDate,\n        av.KeyTypeSelect, av.KeyTypeMSelect, av.KeyTypeURL,\n        av.KeyTypeEmail, av.KeyTypePhone, av.KeyTypeMAsset,\n        av.KeyTypeCheckbox, av.KeyTypeRelation:\n        return true\n    }\n    return false\n}\n\nfunc validateTemplateKeyType(key *av.Key) error {\n    if !isNormalizableKeyType(key.Type) {\n        return fmt.Errorf(\"key type %q is not supported in new-item templates\", key.Type)\n    }\n    return nil\n}","typeGuard":"func isTemplateEditableKeyType(t av.KeyType) bool {\n    // Block, Template, Created, Updated, Rollup are non-editable in templates\n    switch t {\n    case av.KeyTypeBlock, av.KeyTypeTemplate, av.KeyTypeCreated, av.KeyTypeUpdated, av.KeyTypeRollup:\n        return false\n    }\n    return true\n}","tryCatchPattern":null,"preventionTips":["Filter template FieldValues through isNewItemTemplateEditableKeyType before submitting","Never include block, template, created, updated, or rollup keys in new-item templates","When adding a new KeyType to the av package, update normalizeNewItemTemplateValue's switch and isNewItemTemplateEditableKeyType simultaneously"],"tags":["attribute-view","validation","new-item-template","go"],"backgroundTag":null,"analyzedSha":"251596fc0de2f9528c00c224252fd073a99973f4","analyzedAt":"2026-08-12T21:18:37.123Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}