{"record":{"id":"6e7a38bcc8a58bd9","repo":"siyuan-note/siyuan","slug":"phone-value-is-missing","errorCode":null,"errorMessage":"phone value is missing","messagePattern":"phone value is missing","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"kernel/av/new_item_template.go","lineNumber":398,"sourceCode":"\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}\n\t\tvalue.Text, value.Number, value.Date, value.MSelect, value.Email, value.Phone, value.MAsset, value.Checkbox, value.Relation = nil, nil, nil, nil, nil, nil, nil, nil, nil\n\tcase KeyTypeEmail:\n\t\tif nil == value.Email {\n\t\t\treturn nil, errors.New(\"email value is missing\")\n\t\t}\n\t\tvalue.Text, value.Number, value.Date, value.MSelect, value.URL, value.Phone, value.MAsset, value.Checkbox, value.Relation = nil, nil, nil, nil, nil, nil, nil, nil, nil\n\tcase KeyTypePhone:\n\t\tif nil == value.Phone {\n\t\t\treturn nil, errors.New(\"phone value is missing\")\n\t\t}\n\t\tvalue.Text, value.Number, value.Date, value.MSelect, value.URL, value.Email, value.MAsset, value.Checkbox, value.Relation = nil, nil, nil, nil, nil, nil, nil, nil, nil\n\tcase KeyTypeMAsset:\n\t\tvar assets []*ValueAsset\n\t\tfor _, asset := range value.MAsset {\n\t\t\tif nil != asset && \"\" != strings.TrimSpace(asset.Content) {\n\t\t\t\tif AssetTypeFile != asset.Type && AssetTypeImage != asset.Type {\n\t\t\t\t\treturn nil, fmt.Errorf(\"invalid asset type [%s]\", asset.Type)\n\t\t\t\t}\n\t\t\t\tassets = append(assets, asset)\n\t\t\t}\n\t\t}\n\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}","sourceCodeStart":380,"sourceCodeEnd":416,"githubUrl":"https://github.com/siyuan-note/siyuan/blob/251596fc0de2f9528c00c224252fd073a99973f4/kernel/av/new_item_template.go#L380-L416","documentation":"Thrown inside normalizeNewItemTemplateValue (kernel/av/new_item_template.go:397-398) when key.Type == KeyTypePhone but value.Phone is nil. The normalizer clones the Value and nulls out all sub-fields except Phone, so a nil *ValuePhone makes the template field unusable. The strict path wraps it as \"new item template field [<keyID>] value is invalid: phone value is missing\"; the prune path silently drops the entry.","triggerScenarios":"Saving an Attribute View new-item template with a static-mode field whose key type is \"phone\" but whose Value object lacks a non-null \"phone\" sub-field.","commonSituations":"Reusing a generic Value payload across field types in template creation; frontend deserialization that leaves optional pointers as nil; schema migration from a version without phone fields.","solutions":["Include a non-null phone object in the value JSON, e.g. {\"phone\": {\"content\": \"+1-555-0100\"}}","Omit the field from FieldValues entirely if no default phone value is needed","Set Value.Phone = &ValuePhone{Content: \"...\"} before saving"],"exampleFix":"// before\nfieldValue.Value = &av.Value{Type: av.KeyTypePhone}\n// after\nfieldValue.Value = &av.Value{Type: av.KeyTypePhone, Phone: &av.ValuePhone{Content: \"+1-555-0100\"}}","handlingStrategy":"validation","validationCode":"func validatePhoneValue(value *av.Value, key *av.Key) error {\n    if key.Type == av.KeyTypePhone && value.Phone == nil {\n        return fmt.Errorf(\"phone key requires a non-nil Value.Phone\")\n    }\n    return nil\n}","typeGuard":"func hasPhoneValue(v *av.Value) bool {\n    return v != nil && v.Phone != nil\n}","tryCatchPattern":null,"preventionTips":["Populate Value.Phone with a *ValuePhone before saving a phone-type template field","Use a per-type value constructor to avoid nil sub-fields","Omit the field from the template if no phone default is needed"],"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"}