siyuan-note/siyuan · error

checkbox value is missing

Error message

checkbox value is missing

What it means

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.

Solutions

  1. Include the checkbox object, e.g. {"checkbox":{"checked":true}}
  2. Use the correct value type if a boolean field was not intended
  3. Remove the value so pruning eliminates it
  4. Ensure Value.Checkbox is non-nil for checkbox-typed values before calling

Example fix

// before
{"type":"checkbox"}
// after
{"type":"checkbox","checkbox":{"checked":false}}
Defensive patterns

Strategy: validation

Validate before calling

if v.Type == av.KeyTypeCheckbox && v.Checkbox == nil {
    return fmt.Errorf("checkbox value requires a checkbox object")
}

Type guard

func hasCheckbox(v *av.Value) bool { return v != nil && v.Type == av.KeyTypeCheckbox && v.Checkbox != nil }

Prevention

When it happens

Trigger: Calling PruneInvalidNewItemTemplateFieldValues or normalizeNewItemTemplateFieldValues with a value whose key type is KeyTypeCheckbox but whose Value.Checkbox is nil (checkbox object omitted in template JSON).

Common situations: 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.

Related errors


AI-assisted analysis of siyuan-note/siyuan@9f775e8a12 (2026-09-19). Data as JSON: /api/errors/ca5e1ba8757f7367. Report an issue: GitHub.

Appendix: source

Thrown at kernel/av/new_item_template.go:415

		if nil == value.Phone {
			return nil, errors.New("phone value is missing")
		}
		value.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
	case KeyTypeMAsset:
		var assets []*ValueAsset
		for _, asset := range value.MAsset {
			if nil != asset && "" != strings.TrimSpace(asset.Content) {
				if AssetTypeFile != asset.Type && AssetTypeImage != asset.Type {
					return nil, fmt.Errorf("invalid asset type [%s]", asset.Type)
				}
				assets = append(assets, asset)
			}
		}
		value.MAsset = assets
		value.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
	case KeyTypeCheckbox:
		if nil == value.Checkbox {
			return nil, errors.New("checkbox value is missing")
		}
		value.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
	case KeyTypeRelation:
		if nil == value.Relation {
			return nil, errors.New("relation value is missing")
		}
		for _, blockID := range value.Relation.BlockIDs {
			if !ast.IsNodeIDPattern(blockID) {
				return nil, fmt.Errorf("invalid relation block ID [%s]", blockID)
			}
		}
		value.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
	default:
		return nil, fmt.Errorf("unsupported value type [%s]", key.Type)
	}
	value.Block, value.Template, value.Created, value.Updated, value.Rollup = nil, nil, nil, nil, nil
	value.ID = ""
	value.KeyID = ""

View on GitHub (pinned to 9f775e8a12)