{"record":{"id":"ca5e1ba8757f7367","repo":"siyuan-note/siyuan","slug":"checkbox-value-is-missing","errorCode":null,"errorMessage":"checkbox value is missing","messagePattern":"checkbox value is missing","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"kernel/av/new_item_template.go","lineNumber":415,"sourceCode":"\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}\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 = \"\"","sourceCodeStart":397,"sourceCodeEnd":433,"githubUrl":"https://github.com/siyuan-note/siyuan/blob/251596fc0de2f9528c00c224252fd073a99973f4/kernel/av/new_item_template.go#L397-L433","documentation":"Thrown inside normalizeNewItemTemplateValue (kernel/av/new_item_template.go:414-415) when key.Type == KeyTypeCheckbox but value.Checkbox is nil. The function needs a *ValueCheckbox (which carries a Checked bool) to set as the template default. The strict caller wraps the error; the prune caller silently deletes the field.","triggerScenarios":"Saving an Attribute View new-item template with a static-mode checkbox field whose Value JSON does not include a non-null \"checkbox\" sub-field.","commonSituations":"Programmatic template creation that omits the checkbox payload expecting it to default to unchecked; reusing a generic Value struct; schema migration from a pre-checkbox version.","solutions":["Include a non-null checkbox object, e.g. {\"checkbox\": {\"checked\": false}}","Omit the field from FieldValues if no default checkbox state is needed","Set Value.Checkbox = &ValueCheckbox{Checked: false} before persisting"],"exampleFix":"// before\nfieldValue.Value = &av.Value{Type: av.KeyTypeCheckbox}\n// after\nfieldValue.Value = &av.Value{Type: av.KeyTypeCheckbox, Checkbox: &av.ValueCheckbox{Checked: false}}","handlingStrategy":"validation","validationCode":"func validateCheckboxValue(value *av.Value, key *av.Key) error {\n    if key.Type == av.KeyTypeCheckbox && value.Checkbox == nil {\n        return fmt.Errorf(\"checkbox key requires a non-nil Value.Checkbox\")\n    }\n    return nil\n}","typeGuard":"func hasCheckboxValue(v *av.Value) bool {\n    return v != nil && v.Checkbox != nil\n}","tryCatchPattern":null,"preventionTips":["Set Value.Checkbox = &ValueCheckbox{Checked: false} for checkbox-type template defaults","Omit the field if no default checkbox state 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-13T04:17:16.726Z"}