{"record":{"id":"67b3d740707ddb9b","repo":"siyuan-note/siyuan","slug":"number-value-is-missing","errorCode":null,"errorMessage":"number value is missing","messagePattern":"number value is missing","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"kernel/av/new_item_template.go","lineNumber":366,"sourceCode":"\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}\n\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","sourceCodeStart":348,"sourceCodeEnd":384,"githubUrl":"https://github.com/siyuan-note/siyuan/blob/9f775e8a12daef8255556097396f9b2739078892/kernel/av/new_item_template.go#L348-L384","documentation":"normalizeNewItemTemplateValue, when handling a KeyTypeNumber key, requires the Value to carry a non-nil Number payload. If value.Number is nil the value cannot represent numeric content for the field, so the sentinel error 'number value is missing' is returned and the template configuration fails.","triggerScenarios":"Calling SetNewItemTemplates (static mode) — or PruneInvalidNewItemTemplateFieldValues — with a Value for a number key where the Number sub-field is nil (e.g. a Text payload was supplied instead).","commonSituations":"Populating Value.Text for a numeric field; reusing a value cloned from a text field; deserialized JSON where the Number payload was omitted.","solutions":["Set Value.Number to a &av.ValueNumber with the desired Content before saving","Remove the FieldValues entry if no numeric value is needed","Confirm the key's Type is actually KeyTypeNumber and match the payload accordingly"],"exampleFix":"// before\nfv.Value = &av.Value{Text: &av.ValueText{Content: \"42\"}} // number key\nerr := av.SetNewItemTemplates(config) // number value is missing\n// after\nfv.Value = &av.Value{Number: &av.ValueNumber{Content: 42}}\nerr := av.SetNewItemTemplates(config)","handlingStrategy":"validation","validationCode":"if key.Type == av.KeyTypeNumber && (fv.Value == nil || fv.Value.Number == nil) {\n\treturn fmt.Errorf(\"number key %s requires a Number payload\", keyID)\n}","typeGuard":"func hasNumberPayload(v *av.Value) bool { return v != nil && v.Number != nil }","tryCatchPattern":null,"preventionTips":["Use &av.ValueNumber for numeric fields, never Value.Text as a workaround","Verify key.Type before populating the payload sub-field"],"tags":["attribute-view","validation","value-shape"],"backgroundTag":"invalid-argument-value","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"}