siyuan-note/siyuan · error

phone value is missing

Error message

phone value is missing

What it means

ForKeyTypePhone values, normalizeNewItemTemplateValue demands a non-nil Value.Phone object and otherwise returns 'phone value is missing'. Phone-typed template values lacking the phone payload are structurally invalid and are rejected.

Solutions

  1. Provide the phone object: {"phone":{"content":"+1..."}}
  2. Switch the field/value to text if a plain number was intended
  3. Remove the malformed value before normalization
  4. Check nil Value.Phone in callers and fill or skip accordingly

Example fix

// before
{"type":"phone"}
// after
{"type":"phone","phone":{"content":"+8613800000000"}}
Defensive patterns

Strategy: validation

Validate before calling

if v.Type == av.KeyTypePhone && v.Phone == nil {
    return fmt.Errorf("phone value requires a phone object")
}

Type guard

func hasPhone(v *av.Value) bool { return v != nil && v.Type == av.KeyTypePhone && v.Phone != nil }

Prevention

When it happens

Trigger: PruneInvalidNewItemTemplateFieldValues / normalizeNewItemTemplateFieldValues receives a value with key type KeyTypePhone and a nil Value.Phone pointer (phone object absent from the template payload).

Common situations: Programmatic row creation that sets only Value.Type="phone" and stores the number in Value.Text; generated templates from older schema versions that used a different value shape.

Related errors


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

Appendix: source

Thrown at kernel/av/new_item_template.go:398

		}
		if KeyTypeSelect == key.Type && 1 < len(selections) {
			selections = selections[:1]
		}
		value.MSelect = selections
		value.Text, value.Number, value.Date, value.URL, value.Email, value.Phone, value.MAsset, value.Checkbox, value.Relation = nil, nil, nil, nil, nil, nil, nil, nil, nil
	case KeyTypeURL:
		if nil == value.URL {
			return nil, errors.New("URL value is missing")
		}
		value.Text, value.Number, value.Date, value.MSelect, value.Email, value.Phone, value.MAsset, value.Checkbox, value.Relation = nil, nil, nil, nil, nil, nil, nil, nil, nil
	case KeyTypeEmail:
		if nil == value.Email {
			return nil, errors.New("email value is missing")
		}
		value.Text, value.Number, value.Date, value.MSelect, value.URL, value.Phone, value.MAsset, value.Checkbox, value.Relation = nil, nil, nil, nil, nil, nil, nil, nil, nil
	case KeyTypePhone:
		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")
		}

View on GitHub (pinned to 9f775e8a12)