{"record":{"id":"a22d2c0b4a2f08da","repo":"siyuan-note/siyuan","slug":"text-value-is-missing","errorCode":null,"errorMessage":"text value is missing","messagePattern":"text value is missing","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"kernel/av/new_item_template.go","lineNumber":361,"sourceCode":"\t\tdefault:\n\t\t\treturn fmt.Errorf(\"invalid new item template field value mode [%s]\", fieldValue.Mode)\n\t\t}\n\t\tfieldValues[keyID] = fieldValue\n\t}\n\tif 0 == len(fieldValues) {\n\t\titemTemplate.FieldValues = nil\n\t} else {\n\t\titemTemplate.FieldValues = fieldValues\n\t}\n\treturn nil\n}\n\nfunc normalizeNewItemTemplateValue(value *Value, key *Key) (*Value, error) {\n\tvalue = value.Clone()\n\tswitch key.Type {\n\tcase KeyTypeText:\n\t\tif nil == value.Text {\n\t\t\treturn nil, errors.New(\"text value is missing\")\n\t\t}\n\t\tvalue.Number, value.Date, value.MSelect, value.URL, value.Email, value.Phone, value.MAsset, value.Checkbox, value.Relation = nil, nil, nil, nil, nil, nil, nil, nil, nil\n\tcase KeyTypeNumber:\n\t\tif nil == value.Number {\n\t\t\treturn nil, errors.New(\"number value is missing\")\n\t\t}\n\t\tvalue.Text, value.Date, value.MSelect, value.URL, value.Email, value.Phone, value.MAsset, value.Checkbox, value.Relation = nil, nil, nil, nil, nil, nil, nil, nil, nil\n\tcase KeyTypeDate:\n\t\tif nil == value.Date {\n\t\t\treturn nil, errors.New(\"date value is missing\")\n\t\t}\n\t\tvalue.Text, value.Number, value.MSelect, value.URL, value.Email, value.Phone, value.MAsset, value.Checkbox, value.Relation = nil, nil, nil, nil, nil, nil, nil, nil, nil\n\tcase KeyTypeSelect, KeyTypeMSelect:\n\t\tvar selections []*ValueSelect\n\t\tfor _, selection := range value.MSelect {\n\t\t\tif nil != selection && \"\" != strings.TrimSpace(selection.Content) {\n\t\t\t\tselections = append(selections, selection)\n\t\t\t}","sourceCodeStart":343,"sourceCodeEnd":379,"githubUrl":"https://github.com/siyuan-note/siyuan/blob/251596fc0de2f9528c00c224252fd073a99973f4/kernel/av/new_item_template.go#L343-L379","documentation":"normalizeNewItemTemplateValue for KeyTypeText requires value.Text != nil — the Text sub-struct holds the cell's rendered block content. If a Static-mode value on a Text column omits the Text pointer, normalization cannot proceed.","triggerScenarios":"Static mode on a Text column but the Value carries only Number/Date/MSelect/... sub-fields; client sent a freshly allocated &av.Value{} with no sub-pointer; import mismatch.","commonSituations":"Partial Value from a client that populated the wrong sub-field; type change after the template was authored.","solutions":["Set Value.Text = &av.ValueText{Content: \"...\"} when key.Type is KeyTypeText.","Match the Value sub-pointer to key.Type exactly (see the switch in normalizeNewItemTemplateValue).","Validate the shape client-side before submit."],"exampleFix":"// before\n&av.Value{}  // key.Type == KeyTypeText\n// after\n&av.Value{Text: &av.ValueText{Content: \"Note\"}}","handlingStrategy":"type-guard","validationCode":"if key.Type == av.KeyTypeText && value.Text == nil {\n    value.Text = &av.ValueText{Content: \"\"}\n}","typeGuard":"func hasTextValue(v *av.Value) bool { return v != nil && v.Text != nil }","tryCatchPattern":null,"preventionTips":["Set Value.Text for Text columns before submit.","Match the Value sub-pointer to key.Type exactly.","Add a client-side shape check before the save call."],"tags":["av","new-item-template","text","value","validation"],"backgroundTag":null,"analyzedSha":"251596fc0de2f9528c00c224252fd073a99973f4","analyzedAt":"2026-08-12T21:18:37.123Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}