{"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/9f775e8a12daef8255556097396f9b2739078892/kernel/av/new_item_template.go#L397-L433","documentation":"KeyTypeCheckbox values must carry a non-nil Value.Checkbox object; if the pointer is nil, normalizeNewItemTemplateValue returns 'checkbox value is missing'. A checkbox template value without its boolean payload cannot be normalized and is rejected.","triggerScenarios":"Calling PruneInvalidNewItemTemplateFieldValues or normalizeNewItemTemplateFieldValues with a value whose key type is KeyTypeCheckbox but whose Value.Checkbox is nil (checkbox object omitted in template JSON).","commonSituations":"Templates that represent the checkbox as a plain true/false JSON scalar instead of the expected object; programmatically built Values where only Type was set.","solutions":["Include the checkbox object, e.g. {\"checkbox\":{\"checked\":true}}","Use the correct value type if a boolean field was not intended","Remove the value so pruning eliminates it","Ensure Value.Checkbox is non-nil for checkbox-typed values before calling"],"exampleFix":"// before\n{\"type\":\"checkbox\"}\n// after\n{\"type\":\"checkbox\",\"checkbox\":{\"checked\":false}}","handlingStrategy":"validation","validationCode":"if v.Type == av.KeyTypeCheckbox && v.Checkbox == nil {\n    return fmt.Errorf(\"checkbox value requires a checkbox object\")\n}","typeGuard":"func hasCheckbox(v *av.Value) bool { return v != nil && v.Type == av.KeyTypeCheckbox && v.Checkbox != nil }","tryCatchPattern":null,"preventionTips":["Always wrap the boolean in the Checkbox object","Never construct typed Values with only Value.Type set","Add unit tests covering every key type with a valid payload"],"tags":["attribute-view","validation","nil-value"],"backgroundTag":"null-argument","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"}